Thursday, May 26, 2016

Remove controls from FlowLayoutPanel




How to remove all the controls on the FlowLayoutPanel Control
Today I will show to you the best way to remove any controls inside a FlowLayoutPanel

How to crte a project in Visual Studio?
Exists many ways to crte a new project in VS. For example, when you open your VS program, in theStart Pageyou will see the optionNewProject ...If you can´t see the Start Page you can also click inFile > New Project > Select Visual Basic > Forms AppliionRename your project name if you want and clickOK.It´s sy!

For this demonstration, in the Designer View of the Form add some controls like Buttons, RadioButton ... anything, inside of the FlowLayoutPanel.Now, add a button out of the FlowLayoutPanel. Set the text of this button to "Cln"Double-click the button (to open the file and crte the event .Click)
Paste the next
WhileFlowLayoutPanel1.Controls.Count > 0 'Determine if the flow contains any controls Dim controltoremove = FlowLayoutPanel1.Controls(0) FlowLayoutPanel1.Controls.Remove(controltoremove) controltoremove.Dispose()End While
Now press F5 to Debug the appliion.Click the button and you will see all the controls disappr.

No comments:

Post a Comment