Windows form or web form?
[EDIT]
You could actually pass a reference to your form to your new Class. From there, you can easily iterate the Control collection of the form.
public class MyClass
{
//Change the default constructor to accept a Form object as a parameter
public MyClass(Form MyForm)
{
foreach(Control c in MyForm.Controls)
{
//Do something here
}
}
}
In your form, you may instantiate the MyClass object like so:
MyClass objClass = new MyClass(this);C#: How do I access the form controls from the code of a new class?
create a function in the new class that accepts the form controls as parameters. when you call the function from your code-behind, you just pass in the form control and go from there!C#: How do I access the form controls from the code of a new class?
you get help from http://ccietutorial.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment