Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

i have two forms let say form1 and form2. Form2 has all the controls(datagridview,label,button,groupbox).

My requirement is read all the controls(Id,Name) from form2 in form1 and write it into resource file.

i am able to read all the controls(Id,Name) except datagridview.

How to Get the datagridview columns in form1?

Please help me anyone.

here is my piece of code
--Form1
form2 f=new form2();
foreach (Control cn in f.Controls)
{

if ((cn.GetType() == typeof(System.Windows.Forms.DataGridView)))
{
}


}


thanking you,
Posted
Comments
Ralf Meier 24-Jul-15 3:50am    
I don't understand what you are trying to achieve ... you should give further explaination ...
Bitto kumar 24-Jul-15 5:02am    
I have created a class library project and added a form and it has some control as i mentioned above.And created windows forms project and added a reference to class library project.In windows project i created object for form and able to read all the control ID , Text i,e(suppose it is label(lblFname,FirstName)).The problem is i am getting datagridview Id but i need grid columns also.how to acheive that? I hope u understand. basically my tension is to write all control ID and text values in resource file.
Ralf Meier 24-Jul-15 6:27am    
I'm not sure if I understood you in the right way ...
Could you poste the code-snippet which read the ID from the DGV ?

You have severall Grid-clumns as for example ID, Lastname, Firstname, Date of Birth etc. - now you want to read from the complete DGV all entered data in a File / dataBase ?
antpower943 24-Jul-15 4:25am    
Is the datagridview modifier set as public?
Bitto kumar 24-Jul-15 5:03am    
Yes i made it as public

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