second click on treeview node with no selection change

Posted on 2008-10-06
Last Modified: 2012-06-21
I am working with TreeView in c#. I have an OnSelectedNodeChanged method.
When the user selects a node, it's caught and dealt with. But when the user selects the same node again, I can't catch it because I hadn't found a callback that deal with this.
Question by:Relegence
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
  • 4
  • 3
LVL 18

Expert Comment

ID: 22651351
As event name says, OnSelectedNodeChanged, it is fired when the selected node is changed. In your case, selection is not changing. Use Click event instead.


Author Comment

ID: 22651422
there is no such even for treeview..
i couldn't find any "onclick", "click", "onselect"..

LVL 18

Expert Comment

ID: 22651623
Ah sorry, its an ASP.NET treeview. Yes, you are correct there is no Click event. YTou could get away with this:

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    TreeView1.SelectedNode.Selected = false;

Open in new window

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Author Comment

ID: 22657671
Except i am not changing a node, therefore it never gets there. that's actually my problem, because i do have one OnSelectedNodeChanged method working already.
Again - I need something to catch a Non selection-change-click. Just a click on the Same node.
In this case, postback is called, but how can i catch this event?
LVL 18

Accepted Solution

Priest04 earned 125 total points
ID: 22657735
Relegance, TreeView has a SelectedNodeChanged event. This event is fired when the different node is selected. So, in order to circumvent this, in the SelectedNodeChanged event we set curently selected Node's property Selected to false. Therefore, NO node is currently selected (at least this is what tree view thinks). So, after you click on the selected node AGAIN, it will check whether node that is clicked is selected, and since we set it as unselected, it will raise SelectedNodeChanged event again.

I dont understand what exactly you didnt understand. Or maybe I didnt? :)

Author Comment

ID: 22658318
You are right, now i understand, i must have missed a part.
LVL 18

Expert Comment

ID: 22660585
Then why did you give me B grade? What part of the question is left unanswered?

Featured Post

Independent Software Vendors: 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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

628 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