Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 15.09.10 16:51 
Hi, Delpher,
in einer Listbox habe ich verschiedene Einträge.
In einem Stringgrid habe ich ebenfalls diese Einträge mit Zusatzinformationen.
(wie) kann ich, wenn ich auf einen Eintrag einer Listbox klicke, auf den entsprechenden "Datensatz" im Stringgrid springen?
Geht das?

Vielen Dank für Hilfe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mi 15.09.10 17:05 
Einfach die Zellen des Stringgrids nach dem Eintrag durchsuchen?

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 15.09.10 18:49 
Hallo,

ich liebe einzeilige Code-Lösungen.

eine Spalte(Cols[x]) eines StringGrid ist vom gleichen Typ wie die Items in einer Listbox, es sind TStrings. TStrings bietet IndexOf, also funktioniert folgende Zeile:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.ListBoxClick(Sender: TObject);
begin
  StringGrid.Row := StringGrid.Cols[x].IndexOf(ListBox.Items[ListBox.ItemIndex]);
end;


Sind die Einträge des StringGrid mit denen der Listbox identisch kannst du auch direkt den Index verwenden:
ausblenden Delphi-Quelltext
1:
StringGrid.Row := ListBox.ItemIndex;					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 15.09.10 19:13 
Toll, Lannes!!!
Danke, Detlef

P.S. Ich liebe auch kurze Lösungen!

_________________
ut vires desint, tamen est laudanda voluntas