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

Allow keyboard letters to bring part of list in datagrid

Status
Not open for further replies.

3DDD

Programmer
Oct 15, 2003
30
0
0
US
Hi All

Is there a way to select a row in datagrid list based on keyboard letter pressed?

On datagrid key press event do i need to check each letter pressed or is there any other simple way?

For eg: A datagrid with names such as "Alferdo, Berrano, Germabny, Chinsa, New, Old, Next, Person". If user hit "B" on keyboard, it should select row that starts with "B".

Thanks in advance
 
Thanks for your reply.

Row is selected succesfully.

But how to scroll the grid automatically in order to show the selected row??
 
Code:
DataGrid1.CurrentRowIndex = DataGrid1.CurrentCell.RowNumber
assuming CurrentCell holds the entry you want. If this entry isn't in the viewable area, this will scroll such that the entry is in the bottom, of the viewable area.
 
To scroll such that the entry is at the top, try
Code:
Dim tempCell As New DataGridCell(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)
DataGrid1.CurrentRowIndex = tempCell.RowNumber + DataGrid1.VisibleRowCount
DataGrid1.CurrentRowIndex = tempCell.RowNumber
Again, this assumes that the cell you first column of the cell you want is currently selected.
 
Again, this assumes that the cell you first column of the cell you want is currently selected.
D'OH!
Correction: Again, this assumes the the first column of the cell you want is currently selected.
Sorry, I'm from Kentucky.
 
thanks a lot!!!

Its working if a cell is selected. Is there a way to select just a cell instead of a row?

Thanks a lot:)
 
After the above code use
Code:
DataGrid1.CurrentCell = tempCell
I just so happen to be working on a program for work right now with a datagrid, so I've been learning a lot myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top