Solved

Tree view ONClick

Posted on 1998-12-26
5
1,171 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Oops, I think I misunderstand your question, so first you can reject my answer :)


0
 
LVL 4

Expert Comment

by:dwwang
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now