Removing dynamic controls from panel

前端 未结 5 1442
既然无缘
既然无缘 2020-12-03 20:42

I have dynamically generated controls on the panels of windows form and i have also generated a button for removing the controls, all in rows.

int c = 0;
pri         


        
5条回答
  •  星月不相逢
    2020-12-03 21:45

    Remove control events. From MSDN:

    To remove controls from a collection programmatically

    1. Remove the event handler from the event. In Visual Basic, use the RemoveHandler Statement keyword; in Visual C#, use the -= Operator (C# Reference).
    2. Use the Remove method to delete the desired control from the panel's Controls collection.
    3. Call the Dispose method to release all the resources used by the control.

    Specific examples are given using VB and C# in the linked page.

提交回复
热议问题