Solved

Tree view ONClick

Posted on 1998-12-26
5
1,175 Views
Last Modified: 2008-01-09
i having a tree view control problem,when i click on somewhere on the tree view not the node it also fire the OnClick Event. how to know that user really click on the node ?
0
Comment
Question by:qwertyuiopasdfghjkl
  • 3
5 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1353167
That shouldn't be happening... Are you sure you've included the code at the corret event??
0
 
LVL 4

Accepted Solution

by:
dwwang earned 30 total points
ID: 1353168
The Onclick event is triggered when user click on anywhere on the treeview, if you want to know when user click on the node, you need to use OnExpanding event.

Regars,
Wang
0
 

Author Comment

by:qwertyuiopasdfghjkl
ID: 1353169
yes i do....the code is following, but when the program start, tree view will automatically default highlight the first node, that means the node is selected and when the user click on somewhere else on the tree view, the event will be fire and the line below will be execute too.

procedure Onclickevent(Sender : Toject);
begin
if TreeView1.Selected.Text = 'Node1' then
     Showmessage('node1 been choosen'); //this line will be execute whenever the user                                                               click on somewhere else on the tree view
end;

0
 
LVL 4

Expert Comment

by:dwwang
ID: 1353170
Oops, I think I misunderstand your question, so first you can reject my answer :)


0
 
LVL 4

Expert Comment

by:dwwang
ID: 1353171
However, you can use this procedure to do what you need:

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

var
  HT : THitTests;
begin
  begin
  with Sender as TTreeView do
    begin
    HT := GetHitTestInfoAt(X,Y);
    if (htOnItem in HT) then
      if GetNodeAt(X,Y).text='Node1' then Showmessage('node1 been choosen');;
    end;
  end;
end;

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question