Click here to Skip to main content
15,895,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends, I have requirement, i will getting the all Control id's of all forms at one place using c#.net.

how to do this task in windows application using c#.net

please any one help me..
Posted

1 solution

hi,
Do you mean ,You want to get all the controls(child controls) of a form.
If so then in button click place this code.
C#
foreach (Control ctrl in this.Controls)
{
    string ControlNames = ctrl.Name;
    string controlTypes = ctrl.GetType().ToString();
}
 
Share this answer
 
Comments
CH Guravaiah 22-Jul-13 4:36am    
yes but not a single form. for all forms in my application.
syed shanu 22-Jul-13 4:41am    
Yes you can use the same to get all the forms control list
first get all your forms name for example
This link will give you to collect all forms inside your project.
http://www.codestructs.com/tag-blogger-com-1999-blog-2555797619867133640-post-8228795221278334972
and use this method to get all controls inside your form
frmNew obj = new frmNew();

foreach (Control ctrl in obj.Controls)
{
string ControlNames = ctrl.Name;
string controlTypes = ctrl.GetType().ToString();
}

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