I've tried to create an invisible clickable button, but when I click it, nothing happens...
The code I used to make the button invisible:
button1.Visible = false;
I want to show a picture when the button is clicked (after it's been made invisible)
Try this instead of Invisible property:
button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderColor = BackColor;
button1.FlatAppearance.MouseOverBackColor = BackColor;
button1.FlatAppearance.MouseDownBackColor = BackColor;
Try this
private void CreateButton()
{
button1 = new Button();
button1.FlatAppearance.BorderSize = 0;
button1.FlatAppearance.MouseDownBackColor = Color.Transparent;
button1.FlatAppearance.MouseOverBackColor = Color.Transparent;
button1.FlatStyle = FlatStyle.Flat;
button1.ForeColor = BackColor;
button1.Location = new Point(197, 226); //Give your own location as needed
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 0;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += this.button1_Click;
Controls.Add(button1);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("clicked");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With