I have 2 forms, on the first one there are a lot of buttons (the name is not known beforehand), when I click on one of them, another button appears (Delete), after clicking on which a window is displayed confirming the action, where you need to select yes / no. If so, you need to remove the button on the first form. How to do this? I would be grateful for an example
1 answer
private Control controlToRemove = null; private void button3_Click(object sender, EventArgs e) { // каким-то образом определяется, что нужно будет удалить. Например: controlToRemove = (Control)sender; } private void btnRemove_Click(object sender, EventArgs e) { if (controlToRemove != null) { if (/* показали второе окно и пользователь сказал "Да" */) { controlToRemove.Parent.Controls.Remove(controlToRemove); } } } - A little bit wrong, but I completed it myself. Thank you for sending where necessary! - Vyacheslav
|
btnToRemove.Parent.Controls.Remove(btnToRemove);- Igor