Solved

TreeListView Selected Item Woes

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

791 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