Solved

TreeListView Selected Item Woes

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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