A
Andy Baker
I have a VB.NET 2003 application that uses several datagrids. The behaviour
I want from the datagrid is to select (highlight) the entire row when I
click on any cell in a row. I have done this using code from syncfuson.com
to create a class that inherits from DataGridTextBoxColumn and overrides the
its Edit method. i.e.
Public Class DataGridNoActiveCellColumn
Inherits DataGridTexBoxColumn
Private SelectedRow as Integer
Protected Overloads Overrides Sub Edit (ByVal source As CurrencyManager,
ByVal rowNum as Integer...)
SelectedRow = rowNum
If (SelectedRow > -1) and (SelectedRow < source.List.Count) then
Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow)
Me.DataGridTableStyle.DataGrid.Select(SelectedRow)
End if
End Sub
End Class
This works well. For certain grids, I want the user to be able to select
more than one row, and each selected row to be highlighted. To attempt to do
this I created another class similar to the above, but without the
Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow) line, and created my
DataGridTableStyle using that, but it didn't work. How can I highlight
multiple rows at the same time in a .NET datagrid? Thanks in advance.
Andy Baker
I want from the datagrid is to select (highlight) the entire row when I
click on any cell in a row. I have done this using code from syncfuson.com
to create a class that inherits from DataGridTextBoxColumn and overrides the
its Edit method. i.e.
Public Class DataGridNoActiveCellColumn
Inherits DataGridTexBoxColumn
Private SelectedRow as Integer
Protected Overloads Overrides Sub Edit (ByVal source As CurrencyManager,
ByVal rowNum as Integer...)
SelectedRow = rowNum
If (SelectedRow > -1) and (SelectedRow < source.List.Count) then
Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow)
Me.DataGridTableStyle.DataGrid.Select(SelectedRow)
End if
End Sub
End Class
This works well. For certain grids, I want the user to be able to select
more than one row, and each selected row to be highlighted. To attempt to do
this I created another class similar to the above, but without the
Me.DataGridTableStyle.DataGrid.Unselect(SelectedRow) line, and created my
DataGridTableStyle using that, but it didn't work. How can I highlight
multiple rows at the same time in a .NET datagrid? Thanks in advance.
Andy Baker