Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleProgrammatically select an entire row in a DataGrid control in Visual Basic 6
DescriptionThis example shows how to programmatically select an entire row in a DataGrid control in Visual Basic 6.
KeywordsDataGrid, select row, data grid, Visual Basic 6
CategoriesControls, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated