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
 
 
 
 
 
TitleSet and use multiple bookmarks in the DBGrid control
KeywordsDBGrid, bookmark
CategoriesControls
 
When the user selects rows, the rows' bookmarks are stored in the DBGrid's SelBookmarks collection. You can save those bookmarks and restore them later to reselect the rows.
 
Private m_SavedBookmarks As Collection

' Save the bookmarks.
Private Sub cmdSaveBookmarks_Click()
Dim i As Integer

    Set m_SavedBookmarks = New Collection
    For i = 0 To DBGrid1.SelBookmarks.Count - 1
        m_SavedBookmarks.Add DBGrid1.SelBookmarks(i)
    Next i

    cmdRestoreBookmarks.Enabled = True
End Sub

' Restore the bookmarks.
Private Sub cmdRestoreBookmarks_Click()
Dim book_mark As Variant

    ' Remove existing bookmarks.
    With DBGrid1.SelBookmarks
        Do While .Count > 0
            .Remove 0
        Loop
    End With

    ' Restore the saved bookmarks.
    For Each book_mark In m_SavedBookmarks
        DBGrid1.SelBookmarks.Add book_mark
    Next book_mark
End Sub
 
Thanks to Bill Matthews.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated