Jump to content

which Node is clicked in uniTreeView


erich.wanker
 Share

Recommended Posts

Hello

 

in a Treeview - i have 3 Nodes with childs ..

 

the Node-values are from 3 dbTables (node1,node2 and node3 are "captions" of the Table-names)

the child-"objects" are db-records

 

i allways get errors if i click a node..

How can i open the right table and record if a user clicks on a object? .. ( i have no TAG-Value to store the unique Integer of a record to a child objekt - just the string value ?)

how can i update a Node - if a new record is stored - or should i clear all items and write everything new?

 

ThanX for informations

uses  ..... uniTreeView, vcl.ComCtrls;
private
     SelectedNode : TUniTreeNode;
create Nodes:var mynode   :TuniTreeNode;
begin
mynode := TUniTreeNode.Create;


UniTreeView1.Items.Clear;


mynode := UniTreeView1.Items.AddNode(nil,nil, 'Mainnode1', Pointer(0), naAddFirst);
          UniTreeView1.Items.AddChild(mynode, 'Object1');
          UniTreeView1.Items.AddChild(mynode, 'Object2');
          UniTreeView1.Items.AddChild(mynode, 'Object3');


mynode := UniTreeView1.Items.AddNode(nil,nil, 'Mainnode2', Pointer(0), naAddFirst);
          UniTreeView1.Items.AddChild(mynode, 'Object1');
          UniTreeView1.Items.AddChild(mynode, 'Object2');
          UniTreeView1.Items.AddChild(mynode, 'Object3');


mynode := UniTreeView1.Items.AddNode(nil,nil, 'Mainnode3', Pointer(0), naAddFirst);
          UniTreeView1.Items.AddChild(mynode, 'Object1');
          UniTreeView1.Items.AddChild(mynode, 'Object2');
          UniTreeView1.Items.AddChild(mynode, 'Object3');
end;
procedure TUniFrame7.UniTreeView1Change(Sender: TObject; Node: TUniTreeNode);
begin
SelectedNode:=Node;
end;
procedure TUniFrame7.UniTreeView1Click(Sender: TObject);
begin
showmessage(SelectedNode.Text +' ... '+ SelectedNode.Parent.Text);  ---> ERROR 
end;

 

 

 

 

Link to comment
Share on other sites

ThanX Farshad   ..all right ... works.. :-)

 

But a small additional question:

 

UniTreeView1.FullExpand;  -> doesn´t work ?

 

AND

 

How can i save a unique number to a child .. 

i am searchin something like: 

 

current_node:=UniTreeView1.Items.AddChild(mynode, 'Object1');
          current_node.ImageIndex:=-1;

          current_node.tag :=  unique_db_recordnumber;

 

 

also for reading the value:

procedure TUniFrame7.UniTreeView1Click(Sender: TObject);
begin
SelectedNode:=UniTreeView1.Selected;
if (SelectedNode <> nil) AND (SelectedNode.Level>0)  then
showmessage(SelectedNode.Text +' ... '+ SelectedNode.Parent.Text + 'RecordNr.:'+inttostr(SelectedNode.tag) );
end;
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...