Solved

How to select current row or particular rows programmatically in multiselect mode?

Posted on 2004-09-12
3
721 Views
Last Modified: 2010-04-05
In multiselect mode, normally we hold ctrl key and click the fixed-row (in the most left part of DBGrid) to select rows.

How to select current row or particular rows programmatically in multiselect mode?

By the way, I've tried this code:

MyDBGrid.SelectedRows.CurrentRowSelected:=True;

But the problem is, the fixed-row is not highlighted.

Any Idea?
0
Comment
Question by:setankabir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 12042230
I just dropped a grid, datasource and TTable on a form and used the DBDemos vendors.db table to illustrate:


procedure TForm1.Button1Click(Sender: TObject);
var bkm: pointer;
begin
  //example to select first, a looked up records and the last
  //record programmatically

  dbgrid1.DataSource.DataSet.DisableControls;
  bkm:= dbgrid1.DataSource.DataSet.GetBookmark;
  dbgrid1.SelectedRows.Clear;
  dbgrid1.DataSource.DataSet.First;
  dbgrid1.SelectedRows.CurrentRowSelected:= true;
  if dbgrid1.DataSource.DataSet.Locate('VendorNo', 3819, [loCaseInsensitive])
  then dbgrid1.SelectedRows.CurrentRowSelected:= true;
  dbgrid1.DataSource.DataSet.Last;
  dbgrid1.SelectedRows.CurrentRowSelected:= true;

  dbgrid1.DataSource.DataSet.GotoBookmark(bkm);
  dbgrid1.DataSource.DataSet.EnableControls;
end;

Regards
Pierre
0
 

Author Comment

by:setankabir
ID: 12053354
I think that approach also won't highlight the fixed-row (in the most left part of DBGrid) as when we manually hold ctrl key and click the fixed-row to select rows.
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 50 total points
ID: 12053733
I tested it on my machine and get exact same results as when doing so manually as when doing so programmatically.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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