I have an application which uses a datagrid to display a property listing. The list will contain around a quarter of a million records so I need the user to have a simple way to search.
I have built a search routine which allows the user to type some text in to a toolstrip bar and then performs a search through the dataset. The issue I have is when the routine finds a match, I need it to highlight the row on the datagrid. This is where I have the problem; I cannot see how to achieve this.
I have tried searching everywhere (Google/Experts Exchange etc) and have seen some pretty ridiculous solutions such as mimicking a user clicking on the mouse.
I also found what I thought were useful ideas such as :
| | DataGrid.Select(DataGrid.CurrentRowIndex) |
I tried this (and similar ones) but it would appear that MS has changed the way Datagrids work in .NET 2. "Overload failed because no accessible 'select' supports this number of arguments".
I also tried setting the 'CurrentRowIndex' property but this even though it exists in the help, when I try to use it I get: "'CurrentRowIndex' is not a member of 'System.Windows.Forms.DataGridView'"
Does anybody know how to programmatically position and highlight a row using VB.NET 2005
Thanks
VB.NET 2005 RC - Datagrid issue
e-Musty
Hi,
I am too seaching for same, I want to seach perticular data, How to do it
Thanks in Advance.
Dr Sardon
You can try (assuming index is the index of the row you want to select).
' Clear the existing selection.
Me.DataGridView1.ClearSelection()
' Select the row.
Me.DataGridView1.Rows(index).Selected = True
' Scroll to the selected row in case it was hidden.
Me.DataGridView1.FirstDisplayedScrollingRowIndex = index
I'm still having troubles selecting the row's header cell. I'm not sure if it's doable.
HTH,
Herbert Hoover
Me.DataGridView1.CurrentCell = Me.DataGridView1.Rows(index).Cells(0)
HTH,
Patti Biggs
thanks , i am searching for the particular row selection and i got it.
Jariibomo
Geoff Darst