Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-12
3
Medium Priority
?
734 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 200 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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