Create invisible clickable button

I tried to create an invisible clickable button but when I click on it nothing happens ...

The code I used to make the button invisible:

button1.Visible = false;

      

I want to show a picture when a button is pressed (after it is invisible)

+3


source to share


3 answers


Try this instead of a property Invisible

:



button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderColor = BackColor;
button1.FlatAppearance.MouseOverBackColor = BackColor;
button1.FlatAppearance.MouseDownBackColor = BackColor;

      

+6


source


try it



 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");
    }

      

+3


source


Start by dragging a new button from the toolbar. By fetching the list of properties instead of doing it manually with code, changing the following parameters should give you the desired result.

| Property                          | Settings    |
---------------------------------------------------
| BackColor                         | Transparent |
| FlatStyle                         | Flat        |
| FlatAppearance.MouseDownBackColor | Transparent |
| FlatAppearance.MouseOverBackColor | Transparent |
| ForeColor                         | Transparent |
| UseVisualStyleBackColor           | False       |

      

0


source







All Articles