🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.delphi
Article #346260

Re: Wybieranie pozycji z XDBGrid

#346260
From: Krzysztof Szyszka
Date: Wed, 24 Jan 2018 15:20
45 lines
2496 bytes
> > Możesz wykonać analogiczną iterację po XDBGrid.SelectedRows, albo skorzystać z metody
> > XDBGrid.ForEachDataRow z parametrem reSelectedRows:
> >
> > function TMainForm.GetSelectedID(DBGrid: TXDBGrid; ID: TField): string;
> > var
> >   ID_List: string;
> > begin
> >   ID_List := '';
> >   DBGrid.ForEachDataRow(reSelectedRows,
> >     procedure
> >     begin
> >       if ID_List = '' then ID_List := ID.Text
> >       else ID_List := ID_List + ', ' + ID.Text;
> >     end);
> >   Result := ID_List;
> > end;
>
> Niestety ForEachDataRow dopiero od D2009 - a ja rzeźbię na D5 :D
> Ale SelectedRows idealnie do tego się nadaje.
> Zrobiłem to tak jak niżej - działa :)
>
> if Lista.SelectedRows.Count > 0 then
>      for i : =0 to Lista.SelectedRows.Count - 1 do Begin
>        TabelaDanych.GotoBookmark(Pointer(Lista.SelectedRows.Items[i]));
>        >> tutaj procedura która ma być wykonana na danych rekordu z TabelaDanych
>      end;

I prawidłowo. A jak całość umieścisz jeszcze w takim bloku jak poniżej, to w XDBGridzie
nie będzie widać, że skaczesz po zaznaczonych rekordach i wrócisz w to samo miejsce.

Lista.DisablePosition;
try
  // tu Twój kod
finally
  Lista.EnablePosition;
end;



-- 
pozdrowienia
Krzysztof Szyszka, X-Files Software
Developer of X-DBGrid Component
Embarcadero Technology Partner
http://www.x-files.pl/ 
Technical Details
Message-ID: <p4a87n$edi$1@node2.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <4f3ead22-d082-4240-9ff7-30a02eb526e7@googlegroups.com> <p4544g$2la$1@node1.news.atman.pl> <60039097-6e57-435c-bab8-b3c7fc71ce47@googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: "Krzysztof Szyszka" <nomail@gazeta.pl>
Newsgroups: pl.comp.lang.delphi
Subject: Re: Wybieranie pozycji z XDBGrid
Date: Wed, 24 Jan 2018 16:20:07 +0100
Organization: ATMAN - ATM S.A.
Lines: 46
Message-ID: <p4a87n$edi$1@node2.news.atman.pl>
References: <4f3ead22-d082-4240-9ff7-30a02eb526e7@googlegroups.com> <p4544g$2la$1@node1.news.atman.pl> <60039097-6e57-435c-bab8-b3c7fc71ce47@googlegroups.com>
NNTP-Posting-Host: 89-77-104-79.dynamic.chello.pl
Mime-Version: 1.0
X-Trace: node2.news.atman.pl 1516807223 14770 89.77.104.79 (24 Jan 2018 15:20:23 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Wed, 24 Jan 2018 15:20:23 +0000 (UTC)
In-Reply-To: <60039097-6e57-435c-bab8-b3c7fc71ce47@googlegroups.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit