Accessing controls of Windows Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a data grid on a windows form that I want to access from another class that's outside the form but in the same project. This other class stores all methods that populate and modify the grid on my form - it basically contains all the logic behind the form. I will be calling these methods from the form class but am not sure how I can access the datagrid from outside the form.

Should my class inherit the form so that it has access to the controls or is there another way of doing this

Thanks for the help!
 
If the datagrid is declared with "Friend" scope, and it is loaded in memory
at the same time the other class is running, you should be able to refer to
it via the form it is on: Form1.DataGrid1.property.


Parveen said:
I have a data grid on a windows form that I want to access from another
class that's outside the form but in the same project. This other class
stores all methods that populate and modify the grid on my form - it
basically contains all the logic behind the form. I will be calling these
methods from the form class but am not sure how I can access the datagrid
from outside the form.
Should my class inherit the form so that it has access to the controls or
is there another way of doing this?
 
Back
Top