Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create invisible clickable button

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)

like image 782
edy Avatar asked Oct 30 '25 20:10

edy


2 Answers

Try this instead of Invisible property:

button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderColor = BackColor;
button1.FlatAppearance.MouseOverBackColor = BackColor;
button1.FlatAppearance.MouseDownBackColor = BackColor;
like image 157
Szer Avatar answered Nov 01 '25 11:11

Szer


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");
    }
like image 30
NASSER Avatar answered Nov 01 '25 10:11

NASSER