Solved

Select rows in a DBGrid.

Posted on 1997-07-23
3
264 Views
Last Modified: 2006-11-17
Hi experts,

How to select / highlight a set of continued records in a DBGrid by mouse clicks and let the program know what are selected? I can't find anything representing the selected row numbers in the DBGrid.

Thank you.
0
Comment
Question by:victorlong
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
y96andha earned 50 total points
ID: 1428757
Use the SelBookmarks property. This comes directly from the online help:

Returns a collection of bookmarks for all selected records in the DBGrid control.

Syntax

object.SelBookmarks

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

When a record is selected in the DBGrid control, its bookmark is appended to the collection returned by the SelBookmarks property.  For example, if you create a clone of the Recordset object created by the DBGrid control, you can process individual data records by repositioning the cloned Recordset with bookmarks taken from the SelBookmarks collection.  

0
 

Author Comment

by:victorlong
ID: 1428758
Hi y96andha...(Sorry, not your first name :-)),

Thank you for your reply and help. You may know I am a beginer...I still not really understand:

1) When select the rows in a DBGrid, I can't find the way like sececting continued files in Windows by Shift + Click.
2) What the DBGrid.SelBookmarks really represents? Is that the row numbers or need to add another dot and somthing like DBGrid.SelBookmarks(i).row

Cheers.

Victor
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1428759
This is a code sample to get a selected record:

dim rs as recordset
rs = dbgrid1.recordset.clone
rs.bookmark = dbgrid1.selbookmarks(1)

rs is now positioned at the first selected record of the DBGrid.




0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question