Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Select rows in a DBGrid.

Posted on 1997-07-23
3
Medium Priority
?
285 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 150 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 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