[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Tree view ONClick

Posted on 1998-12-26
5
Medium Priority
?
1,180 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 120 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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