Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DBGrid.SelectedRows

2,828 views
Skip to first unread message

merlin

unread,
Apr 18, 1999, 3:00:00 AM4/18/99
to
I Have a problem with DBGrid RowSelected .
How can I find out which Rows are selected.
If I reed the Bookmarklist of the Grid, I read a '#2' only in every Item.

Please give me a Sourcecode for Delete all selected Rows of a Grid.

Thanks Frank
FRoe...@LDT-Gera.de


Roman Krejci

unread,
Apr 18, 1999, 3:00:00 AM4/18/99
to
merlin píše ve zprávě <7fcloq$pb...@forums.borland.com>.

>I Have a problem with DBGrid RowSelected .
>How can I find out which Rows are selected.
>If I reed the Bookmarklist of the Grid, I read a '#2' only in every Item.
>
>Please give me a Sourcecode for Delete all selected Rows of a Grid.
>


Deleting selected records:
----------------------------------------

........Grid.SelectedRows.Delete

Iterating all selected records:
----------------------------------------

For i := 0 to Grid.SelectedRows.Count -1 do begin
{ GoTo selected record: }
Grid.datasource.dataset.Bookmark := Grid.SelectedRows.Items[i];
{ Do something with i-th selected record }
..................
end;

--
Roman
(please remove 'stopspam' in header when replying)
mail: in...@rksolution.cz
URL: www.rksolution.cz


Bill Todd

unread,
Apr 18, 1999, 3:00:00 AM4/18/99
to
procedure TfrmGrid.Button1Click(Sender: TObject);
var
i:integer;
begin
For i:=0 to DBGrid1.SelectedRows.Count -1 do begin
Table1.GoToBookmark(TBookmark(DBGrid1.SelectedRows[i]));
Table1.Delete;
end;
end;

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
for any other reason remove nospam from my address.)

merlin

unread,
Apr 19, 1999, 3:00:00 AM4/19/99
to

Bill Todd <bi...@nospam.dbginc.com> schrieb in im Newsbeitrag:
7fdvrj$qv...@forums.borland.com...

> procedure TfrmGrid.Button1Click(Sender: TObject);
> var
> i:integer;
> begin
> For i:=0 to DBGrid1.SelectedRows.Count -1 do begin
> Table1.GoToBookmark(TBookmark(DBGrid1.SelectedRows[i]));
> Table1.Delete;
> end;
> end;
>
> Bill
>
> --
>

Thanks Bill !

I had full success. But I have your sourcecode changed minimal.
The Counter must go down. If you delete a Record, the other Records will
glides up.
So the other Bookmarks show to the wrong Records.

for i:=DBGrid1.SelectedRows.Count-1 downto 0 do
begin
Table1.GoToBookmark(TBookmark(DBGrid1.SelectedRows[i]));
Table1.delete;
end;
DBGrid1.SelectedRows.Clear;


0 new messages