Board index » delphi » Multiple Row Selection using DBGrid

Multiple Row Selection using DBGrid

Hello all,

I'm presently working on an application using Delphi 2.0 and Pradox 7.0
tables. I want to be able to select multiple rows from a DBGrid and then
individually manipulate each selected row's contents. Anybody have a clue on
how this can be done? Can it be done?

Thanks in advance,

Sergio
Montreal,Canada

email:sergio_m...@accent.net
email:ser...@pils.com

 

Re:Multiple Row Selection using DBGrid


I would not think it possible, since selecting more than one row in a
DBGrid is like trying to position the record pointer to two or more
records.

You could load into a string grid and select more than one row, but you
have to deal with synchronization issues.  I would like to know the answer
to your quesiton as well.

k...@anatec.com

Sergio Masciotra <sergio_m...@accent.net> wrote in article
<506hjr$...@faith.total.net>...

Quote
> Hello all,

> I'm presently working on an application using Delphi 2.0 and Pradox 7.0
> tables. I want to be able to select multiple rows from a DBGrid and then
> individually manipulate each selected row's contents. Anybody have a clue
on
> how this can be done? Can it be done?

> Thanks in advance,

> Sergio
> Montreal,Canada

Re:Multiple Row Selection using DBGrid


Quote
> Sergio Masciotra <sergio_m...@accent.net> wrote in article
> > Hello all,

> > I'm presently working on an application using Delphi 2.0 and Pradox > > 7.0 tables. I want to be able to select multiple rows from a DBGrid > > and then individually manipulate each selected row's contents.
> > Anybody have a clue on how this can be done? Can it be done?

> > Thanks in advance,

        It can be done.  This feature is not very well documented.
        What you have to do is
        1) Set MutliSelect = True for your TDBGrid
        2) Iterate through a series of Bookmarks to retrieve
           the selected rows.

        Look at the source (dbgrids.pas).  If you need more
        help just send me some email.

        brant
        ...

Re:Multiple Row Selection using DBGrid


The only way to manipulate multiple selections
in a DBGrid is by using its SelectedRows
property.  SelectedRows returns a
TBookmarkList object which is just like a
TList but it contains bookmarks for all the
selected rows in the DBGrid.  Both the
SelectedRows and TBookmarkList object
are NOT in the Delphi help.  According to
Borland, these were last minute things
that were added, so they didn't make it
into the help.  The following code
manipulates the selected rows of a
DBGrid:

Var
    RowsHighlighted: TBookmarkList;
    i: integer;

begin
    RowsHighlighted := TBookmarkList.Create;
    RowsHighlighted := DBGrid1.SelectedRows;
    for I := 0 to RowHighlighted.Items.Count - 1 do begin

        //use each bookmark here to manipulate rows

    end;
    RowsHighlighted.Clear;
    RowsHighlighted.Free;
end;

Quote
> Leong San Io Francisco <d941...@umac.mo> wrote in article

<Pine.SOL.3.91.960910105804.28073H-100000@umacux2>...
Quote
> On 31 Aug 1996, Kenneth A. Faw wrote:

> > > Hello all,

> > > I'm presently working on an application using Delphi 2.0 and Pradox
7.0
> > > tables. I want to be able to select multiple rows from a DBGrid and
then
> > > individually manipulate each selected row's contents. Anybody have a
clue
> > on
> > > how this can be done? Can it be done?

> > > Thanks in advance,
>    If I'm not wrong, Delphi 2.0 supports MultiSelect attribute in the
> TDBGrid. Just enable it. Then you can use Selected.Delete to delete the
> selected records, etc. Selected is just an object of bookmarks. It is
not
> present in the help, but if you read the source code, you'll know.

> Francisco leong
> d941...@umac.mo

Re:Multiple Row Selection using DBGrid


On 31 Aug 1996, Kenneth A. Faw wrote:

Quote
> > Hello all,

> > I'm presently working on an application using Delphi 2.0 and Pradox 7.0
> > tables. I want to be able to select multiple rows from a DBGrid and then
> > individually manipulate each selected row's contents. Anybody have a clue
> on
> > how this can be done? Can it be done?

> > Thanks in advance,

        If I'm not wrong, Delphi 2.0 supports MultiSelect attribute in the
TDBGrid. Just enable it. Then you can use Selected.Delete to delete the
selected records, etc. Selected is just an object of bookmarks. It is not
present in the help, but if you read the source code, you'll know.

Francisco leong
d941...@umac.mo

Other Threads