Hello,
As Karthik sir said, you can pass that control to the method in another class.Like this :
public Class c1()
{
public void method(control c)
{
}
}
Main:
c1 c = new c1();
c.method(any_control);
I can also do something like this :
public class c1()
{
control c;
public c1(control c)
{
this.c = c;
}
public void method()
{
TextBox t = (TextBox)this.c;
}
}
In the Main method :
c1 c = new c1(any_control);
Please note, the Control class is the base class of all controls(correct me if i am wrong).
So to make this algorithm generalized i can use the Control type to become the argument of a constructor or a method.
- I have used a constructor because it may happen that during class initialization you want to perform some operation with that control
Thanks,
-Rahul