Button bn = new Button();
bn.Location = new System.Drawing.Point(560, 350);
bn.Name = "btnDelete";
bn.Text = "Delete";
bn.Size = new System.Drawing.Size(100, 50);
myTabPage.Controls.Add(bn);
I have positioned the button, what property would I use to add code behind the button?
Pretty easy:
bn.Click += MyClick;
...
private void MyClick(object sender, EventArgs e) {
MessageBox.Show("hello");
}
Here you're registering a click event and specify the code that runs when the event fires.
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