|
|
Title | Set and use multiple bookmarks in the DBGrid control |
Keywords | DBGrid, bookmark |
Categories | Controls |
|
|
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.
|
|
|
|
|
|