Solved

TreeListView Selected Item Woes

Posted on 2006-06-18
2
199 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

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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 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

14 Experts available now in Live!

Get 1:1 Help Now