Autor Beitrag
ensacom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 24.03.09 16:48 
Ist es möglich in einer TreeView neben dem Text unsichtbar auch eine Zahl zu hinterlegen?
Ich möchte also das jeder Eintrag in einer TreeView nur einen Text anzeigt ich aber, wenn ich diesen Eintrag anklicke,
auch den Integerwert ausgegeben bekomme.

Danke
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 24.03.09 17:14 
Hallo,

ja, geht über die Data-Eigenschaft einer node.
ein bsp von Narses findest Du www.delphi-library.d...Highscore_70217.html, ist zwar für ein Listview, aber das prinzip der Zuwesiung etc ist dasselbe

Gruß Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
ImbaPanda
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 98

Windows XP/Vista
Delphi 7 Professional/ Rad Studio 2009
BeitragVerfasst: Di 24.03.09 17:17 
Eine Möglichkeit wäre dem Statusindex des jeweiligen TreeNodes einen Integerwert zuzuordnen.
ausblenden Delphi-Quelltext
1:
TreeView.Items[irgendeineZeile].StatusIndex := ?					
ensacom1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 24.03.09 22:46 
Hm so sollte doch der Integerwert nun im Treeview gespeichert sein.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
while not cdsTippliste.eof do
begin
  IntVar := cdsTippliste.FieldByName('id').asInteger;
  TreeView1.Items.AddChildObject(nc, cdsTippliste.FieldByName('titel').asString, Pointer(IntVar));
  cdsTippliste.Next;
end;


Zumindest geht es so bei ComboBoxen.

Aber wie lese ich den Wert nun aus?
Bei einer ComboBox mache ich es so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.ComboBox1Select(Sender: TObject);
var
  IntVar: Integer;
begin
  intVar := Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
  label1.Caption := ComboBox1.Text;
  label2.Caption := inttostr(intVar);
end;


Bei der TreeView finde ich aber nichts mit Object.

Kann mir einer helfen?

Danke
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.03.09 06:27 
user profile iconensacom1 hat folgendes geschrieben Zum zitierten Posting springen:
Bei der TreeView finde ich aber nichts mit Object.
Nein, kein Wunder:
user profile iconKeldorn hat folgendes geschrieben Zum zitierten Posting springen:
ja, geht über die Data-Eigenschaft einer node.

ausblenden Delphi-Quelltext
1:
ShowMessage(IntToStr(Integer(TreeView1.Selected.Data)));					
ensacom1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mi 25.03.09 09:48 
Vielen Dank jaenicke, das hat funktioniert.
Echt ein klasse Forum.