Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
All the properties of the Form should be available in the class like textbox, button etc.
Initially I know how to pass the form object to another class but the properties of the form I'm unable to fetch it. As I have to get the values of some textboxes present in the form in class.
Posted
Comments
BillWoodruff 6-Feb-15 2:33am    
"I know how to pass the form object to another class" If you do, indeed pass a valid reference to an instnace of a Form into an instance of Class, your Class will have access to everything in that Form, so this doesn't quite make sense. Since you don't show your code that passes the Form to the Class, we cannot know why you are not able to access the Form's Controls, properties, etc.

So, show your code.

1 solution

Hi
You can try as below :

C#
public yourclassconstructor(Form1 frm )
{
  TextBox txtBox  = (TextBox)frm.Controls["textBox1"];
  string text = txtBox.Text;
}




Regards
Dominic Abraham
 
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