Board index » delphi » TreeView - Selected Item ID

TreeView - Selected Item ID

I am using Delphi 6.0 and the TTreeView that comes with Delphi.

Is there a way when you create an Item to give it an KeyValue (unique ID
that I assign from an ADO DataSet), and when the user double clicks on the
Item, for me to read the KeyValue that I assigned.

I cannot figure out how to do this and I am not sure if I am populating the
TreeView correctly.

Thanks you in advance.

--

God Bless you,
Marco Napoli
http://www.ourlovingmother.org

 

Re:TreeView - Selected Item ID


Marco ,

Quote
> I am using Delphi 6.0 and the TTreeView that comes with Delphi.

> Is there a way when you create an Item to give it an KeyValue (unique ID
> that I assign from an ADO DataSet), and when the user double clicks on the
> Item, for me to read the KeyValue that I assigned.

> I cannot figure out how to do this and I am not sure if I am populating
the
> TreeView correctly.

Have a look at the Data property of TTreeNode. Use it as a container for
your ID. Although it's declared as a Pointer, you could store an integer
value in there by using a type cast.

Martin

Re:TreeView - Selected Item ID


In the TreeView double Click Event I have the following code and your
suggestion worked.

var i: Integer;
begin
    i := Integer(TreeView.Selected.Data);
end;

Thank you.

Quote
"Martin Kammann" <mNokammannS...@intellience.com> wrote in message

news:3b7356a6_1@dnews...
| Marco ,
|
| > I am using Delphi 6.0 and the TTreeView that comes with Delphi.
| >
| > Is there a way when you create an Item to give it an KeyValue (unique ID
| > that I assign from an ADO DataSet), and when the user double clicks on
the
| > Item, for me to read the KeyValue that I assigned.
| >
| > I cannot figure out how to do this and I am not sure if I am populating
| the
| > TreeView correctly.
|
| Have a look at the Data property of TTreeNode. Use it as a container for
| your ID. Although it's declared as a Pointer, you could store an integer
| value in there by using a type cast.
|
| Martin
|
|

Other Threads