Board index » delphi » Multiple Selection from a DBGRID

Multiple Selection from a DBGRID

Hello

I am just need to know how can you select multiple rows from a dbgrid
then on the click of a button, pass those selections to, say, a memo or
listbox.

I have tried everywhere, Delphi Magazine, Delphi Help, etc, nowhere can
I find any information or examples.

Please , please help , it is very important that I find out how to do
this.

Thank you for help, all info, examples, etc. will be greatly
appreciated, believe me!!!!!!
--
Russell Willis
Software Engineer
NiSoft (UK) Ltd.

 

Re:Multiple Selection from a DBGRID


Hi Russell,

You must use SelectedRows property of TDBGrid. It references to
TBookmarkList object and that contains bookmarks of all selected rows. Then
you can list through selected rows by something like:

with DBGrid1.SelectedRows do
  for i := 0 to Count - 1 do
  begin
    // set current record by bookmark
    Table1.Bookmark := Items[i];
    // read field values from current record
    ShowMessage(Table1.FieldByName('CustomerName').AsString);
  end;

HTH

Martin Schayna
mscha...@aktis.cz

Quote
Russell Willis wrote in message ...
>Hello

>I am just need to know how can you select multiple rows from a dbgrid
>then on the click of a button, pass those selections to, say, a memo or
>listbox.

>Russell Willis
>Software Engineer
>NiSoft (UK) Ltd.

Re:Multiple Selection from a DBGRID


It is good idea to use TRxDBGrid instead of TDbGrid from RxLibrary for Delpi.
This component can resolve your problem and have many useful properties and
events.

You can find it at
  ftp:   sunsite.mff.cuni.cz
  dir:  /MIRRORS/sunsite.icm.edu.pl/pub7/delphi/ftp/
  file: rxlib240.zip

PS.  Mail directly to me for help in component using.

Quote
>Hello

>I am just need to know how can you select multiple rows from a dbgrid
>then on the click of a button, pass those selections to, say, a memo or
>listbox.

>I have tried everywhere, Delphi Magazine, Delphi Help, etc, nowhere can
>I find any information or examples.

>Please , please help , it is very important that I find out how to do
>this.

>Thank you for help, all info, examples, etc. will be greatly
>appreciated, believe me!!!!!!
>--
>Russell Willis
>Software Engineer
>NiSoft (UK) Ltd.

--

--  Zenyk Mykytjuk  -----------------------------------------------------

  Rybatska str. 28            mail to:    ze...@farma.il.if.ua
  285200, Kolomyja,           voice:      +380 (03433) 2-38-91 (home)
  Ivano-Frankiwska obl.       voice/fax:  +380 (03433) 2-35-79 (office)
  Ukraine                     voice/fax:  +380 (03433) 2-49-37 (office)

-------------------------------------------------------------------------

Other Threads