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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus on the first cell in a DataGrid

Status
Not open for further replies.

mattyboy2000

Programmer
Jul 31, 2002
129
GB
Hi,

I have a form with one control on it ( a datagrid). When It loads I want the first cell to have focus (As you would expect). I databing it to a data table and then call the following lines:

Me.dgVATCodes.CurrentCell = New DataGridCell(0, 0)
Me.dgVATCodes.Focus()

The problem is that it does nothing!!!

If I do:

Me.dgVATCodes.CurrentCell = New DataGridCell(0, 1)
Me.dgVATCodes.Focus()

It focuses on the second cell (No probs)

Any Ideas???

Matt
 
I cant get the first column (0) to receive focus no matter what row it is. It works perfectly on columns greater than the 2nd (1).
 
have you tried datagrid.select(0) ?

it works fine for me
//icca /icca
 
This solution selects the whole row.

I need to Focus ONLY on the first cell of the first row (0,0). Any Ideas??
 
I was thinking about sending a tab however many spaces it takes to get to the grid....but I don't like the send keys function.
 
yeah. sorry didn't read it carefully enough..
but dg.focus() does focus the first cell in my app.
why are you creating a new cell?

//icca
 
I'm not really creating a new cell.

The current cell property returns a DataGridCell that only has the column and row numbers. by setting it to a new cell (0,1) I am giving it new coordinates

I know it doesn't make mutch sence, but it's how it works

Matt
 
well.. if it doesn't make sence is it probably not a very good solution..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top