Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Get "Selection set" from DBGrid?

Is it possible to get a selection set from a DBGrid.
By setting dgMultiSelect to True, it is possible to select more than one record. I want to be able to get for example: Field number 3 in the second selected record, or the whole fifth selected record for example.

I run Delphi Developer 2.0 and the table is a DBase-table...

Thanx!
Erik N.
0
Erik N
Asked:
Erik N
  • 2
  • 2
1 Solution
 
ronit051397Commented:
1. See explanation in the file manuals.txt.
2. example:

var I, J: Integer;

  with DBGrid.SelectedRows, Table1 do //the records from the grid
                                        belong to Table1
  for I:=0 to Count-1 do //do some actions only on the selected                            records
  begin
    Find(Items[I],J);
    Bookmark:=items[I];
    Edit;
    //do something with the current selected record
    Post;
  end;
0
 
ZifNabCommented:
In the multi selected records case, Borland recommands to use the
Find method and not the GotoBookmark method (I Don't know why),
See the manuals.txt file.

0
 
ronit051397Commented:
Ronit,

10x for the advise!

ZifNab.
0
 
ZifNabCommented:
Thank you Ronit, for your good answer.
I also thanks ZifNab for his comment, it helped a lot!

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now