Solved

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

Posted on 2006-07-21
2
838 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
ID: 17158338
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
ID: 17164593
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

20 Experts available now in Live!

Get 1:1 Help Now