Solved

Check selected TreeView Node is parent or not

Posted on 2007-03-22
3
1,377 Views
Last Modified: 2007-12-19
Hi..
How to check the selected TreeView node is a parent node or not ?

I am implementing a drag and drop facility to in the TreeView. Condition is if the parent node tries to drag it should not allow, only the child should allow to move to any other parent.

Thanks in advance

sun4sunday
0
Comment
Question by:sun4sunday
[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 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 125 total points
ID: 18770702
Check for

(TreeView.SelectedNode.LastNode!=null) // means its parent


or
(TreeView.SelectedNode.Nodes.Count >0l) //,means it has some nodes ..its a parent
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 125 total points
ID: 18775307
You might also want to check first that SelectedNode itself isn't null...

if (TreeView1.SelectedNode != null)
{
    if (TreeView1.SelecedNode.Parent != null)
   {
      // the TreeNode is a child...
   }
}
0
 
LVL 9

Author Comment

by:sun4sunday
ID: 18797724
Thanks for the solutions
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 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