Solved

Tree view ONClick

Posted on 1998-12-26
5
1,177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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