|
|
Title | Programmatically select an entire row in a DataGrid control in Visual Basic 6 |
Description | This example shows how to programmatically select an entire row in a DataGrid control in Visual Basic 6. |
Keywords | DataGrid, select row, data grid, Visual Basic 6 |
Categories | Controls, Database |
|
|
When you click the program's Select button, the following code executes. It removes any previous SelBookmarks from the DataGrid. It then gets the title of the book in the row to be selected and locates the corresponding record in the Recordset that is providing data for the DataGrid. Finally it adds the selected bookmark to the DataGrid's SelBookmarks collection.
|
|
Private Sub cmdSelect_Click()
Dim title As String
' Remove previous bookmarks.
Do While grdBooks.SelBookmarks.Count > 0
grdBooks.SelBookmarks.Remove 0
Loop
' Get the title.
grdBooks.Row = Val(txtRow.Text)
grdBooks.Col = 0
title = grdBooks.Text
' Find this record in the Recordset.
adodcBooks.Recordset.Find "Title = '" & title & "'"
' Select this row.
grdBooks.SelBookmarks.Add adodcBooks.Recordset.Bookmark
End Sub
|
|
|
|
|
|