Solved

c# .net treeview... double click expanding vs executing further processing

Posted on 2006-07-21
2
828 Views
Last Modified: 2012-06-21
Hi Experts!!

I have a treeview in a winforms c#.net app that I want to on double click expand to the child nodes if they exist, if they don't, it considers it the lowest level and calls a process to generate a report.

Right now I have it calling the process successfully but if it is not the lowest level node and they double click, it will call the process as well and that's not good.  So I need to add logic to identify if the selected node has children and if so, just expand to the next level. If not, call the further processing.

I'm not sure how to do that. Can you help me?
0
Comment
Question by:babybird
2 Comments
 
LVL 10

Expert Comment

by:NetworkArchitek
Comment Utility
So in your double click event, assuming the TreeEventArgs argument is called e, then do

if(e.Node.Nodes.Count == 0)
           runProcess();
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 250 total points
Comment Utility
DoubleClick event does NOT contain TreeEventArgs argument ...

        private void treeView1_DoubleClick(object sender, EventArgs e)
        {

            TreeView tv = sender as TreeView;
            TreeNode selected = tv.SelectedNode;
            if (selected == null)
                return;

            if (selected.Nodes.Count == 0)
            {
                runProcess();
            }
            else
            {
                selected.Expand();
            }
        }
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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

9 Experts available now in Live!

Get 1:1 Help Now