Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i want to remove controls from panel in windows form application. i have the dynamic created combobox,Textbox, and button i want to delete these three controls from panel which is in the same row. but only button is remove. i want to delete controls which is in the same row. in the panel many more controls. controls should be delete row by row not all at a time.
Posted
Comments
syed shanu 3-Apr-14 5:11am    
Chk this links http://stackoverflow.com/questions/13888558/removing-dynamic-controls-from-panel

http://stackoverflow.com/questions/2014286/removing-dynamically-created-controls-c-sharp

http://msdn.microsoft.com/en-us/library/82785s1h(v=vs.90).aspx
nandakishoreroyal 3-Apr-14 5:44am    
Update the code what you have tried?
ravikhoda 3-Apr-14 6:39am    
i think you can try panel.controls.clear() method. this will remove all the controls inside the panel.
ZurdoDev 4-Apr-14 8:11am    
If you know how to dynamically add them why can't you remove them?

1 solution

Hello,

If there were a sample code, it would be easier to write a more useful answer. I hope the following makes sense to what you need

Add a GroupBox or some other container of your choice to those items.

C#
//For each control in this container's list of controls
foreach (Control control in aContainer.Controls)
{
     aContainer.Controls.Remove(control);
}


This should help you to remove only the controls you want.

Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900