Solved

TreeListView Selected Item Woes

Posted on 2006-06-18
2
198 Views
Last Modified: 2010-08-05
Basically I have

if (m_myTree.SelectedItems[0].Tag != null)
{
.... some code
}

It seems to fall over once it reaches the first statement in my code because

m_myTree.SelectedItems[0].Tag != null but its not correct either. So I get a mis-match. My main question is why do you use

m_myTree.SelectedItems[0]

If its a tree structure, I am assuming because 0 is the first level for each node in the tree for the selected item when @ 0 is pointing to the leaf etc,
0
Comment
Question by:directxBOB
  • 2
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16932093
if (m_myTree.SelectedItems.Coutnt > 0  &&  m_myTree.SelectedItems[0].Tag != null)
{
.... some code
}

If nothing is selected in the controls, SelectedItems collection is empty and m_myTree.SelectedItems[0] returns null.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16932095
Coutnt - should be Count.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Mutually exclusive checkbox in a gridview 18 41
Windows Service with UDP 2 28
C# code editing and collaboration 3 44
Hide Tab Page 3 19
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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.
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…
This video discusses moving either the default database or any database to a new volume.

757 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

24 Experts available now in Live!

Get 1:1 Help Now