Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid has focus?

Status
Not open for further replies.

amberlynn

Programmer
Dec 18, 2003
502
CA
Hello,
I have a windows form with 2 datagrids on it.
How can I tell which datagrid is selected when a button is pushed?
I tried me.datagrid1.focus = true - but that was never triggered, regardless which datagrid had a selected cell in it.
TIA!
Amber
 
Hi,

I've just build a windows form with two datagrids on it to check it out.... and the thing is that I think that when you select a cell or row, the focus it given to the cell or row therefore the datagrid isn't considered as focused.


I gave both datagrids a dataset as datasource, in run time, i filled the dataset with a simple table.

Now in the datagrid i can navigate to the table or "back to the parent rows" (little arrow on the top right corner of the datagrids). Well, if i navigate back to parent rows (up to the root), the datagrid i'm in is considered as focused.

To check that, i just put a button with some code to test if a datagrid is focused:

Code:
        If DataGrid1.Focus Then
            MsgBox("datagrid1 !!")
        ElseIf DataGrid2.Focus Then
            MsgBox("datagrid2 !!")
        Else
            MsgBox("No datagrid focused !!")
        End If


Although this doesn't give you an answer I hope it will lead you to one.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top