I have created a label using the following code:
public static System.Windows.Forms.PictureBox pc = new PictureBox();
public static System.Windows.Forms.Label la = new Label();
private void label2_Click(object sender, EventArgs e)
{
label2.Visible = false;
pictureBox2.Hide();
Controls.Add(la);
la.Location = new Point(78, 191);
la.Size = new Size(72, 77);
la.Image = _2WaySMSGatewayApp.Properties.Resources.message;
}
I want to be able to create a new label and add it to my form when I click on this label. How can I do that?
You can add a click handler:
Then in the handler:
Edit – Explanation from comments. Your code would look like this: