WinForm and Tab Question

  • Thread starter Thread starter Vai2000
  • Start date Start date
V

Vai2000

Hi All, I have a Tab Control on a windows form. Each of the Tabs collection
have a Datagrid in it.
When I switch a tab, is there a way I can retrieve contents of the Datagrid
which the Tab has focus on?
Right now I am explicitly using dg1 and dg2 and when a certain Form menu is
clicked I explicitly point to the DataGrid. Was looking for a better
solution.


TIA
 
Vai2000,

If you only have one data grid on each tab page, then I would get a
reference to the current tab page, and then cycle through the children until
the type of the Control is a datagrid. Then, you can use it appropriately.

Either that, or I would create a class that extends the TabPage class
which has a property that will return the DataGrid control that is contained
in the TabPage itself, and then call this property on the active tab page.

Hope this helps.
 
Back
Top