How to dynamically delete a button in C #?

I added dynamic expression buttonand number textBoxin my winform application for C #. how can i delete them dynamically? especially if i have the number of identical controls?

+3
source share
2 answers

You need to remove the link from the collection Controlsthat contains them.

frm.Controls.Remove(button1);
+3
source

You can call someContainer.Controls.Remove(someControl).

Alternatively, you can simply Dispose()control.

+2
source

Source: https://habr.com/ru/post/1777074/


All Articles