datagrid entire Row has to be highlighted

blumenhause

Member
Joined
Jun 27, 2006
Messages
5
Programming Experience
Beginner
Data Validation in VB.NET 2003

Thanks alot! That was really helpful..

We do not have internet connection on our work terminals, it has been prevented for security purpose..So I am not able to search the Internet for answers if I have any doubts..But we do have MSDN 2003 installed, but finding information in it not easy..

Could anyone suggest a book, doesnt matter if its a bit advanced coz normal books dont have enough info on DataBinding and on controls such as DataGrid..


'
'
Had to ask one more thing.. When my application loads, the grid is populated by data from Database.. I have to design the Grid in such a way that when the user selects the rows using Mouse or Up/Down Arrow keys, the entire Row has to be highlighted.. I have done this using..
'
'
VB.NET:
Private Sub myDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles myDataGrid.CurrentCellChanged
 
Dim intSelectedRow As Integer = -1
 
If (intSelectedRow <> myDataGrid.CurrentCell.RowNumber) Then
'update the form here
myDataGrid.Select(dgdPatinfo.CurrentRowIndex)
End If
 
' Update the row number with the newly selected row
intSelectedRow = myDataGrid.CurrentCell.RowNumber
End Sub
Eventhough the rows are getting selected, one column will be highlighted, whichever has focus.. If I press the right or left arrow, the selection is gone.. Is there anyway to achieve this.. I could find no way to suppress the Right/Left Arrow keys or controlling the Up/Down Arrow keys using the Grids Keyboard events..

Really appreciate all the suggestions..:)
 
Last edited by a moderator:
This works, (also when using keyboard to navigate cells):
VB.NET:
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] DataGrid1_CurrentCellChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) _
[/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] DataGrid1.CurrentCellChanged
DataGrid1.Select(DataGrid1.CurrentCell.RowNumber)
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
When you set intSelectedRow=-1 the Select statement wasn't called.

Also, moved this post from the original thread (validation topic). Please post unrelated question in new threads, thank you.
 
Back
Top