Click here to Skip to main content
16,005,343 members
Home / Discussions / C#
   

C#

 
AnswerRe: Adding Parameter to a Stored Procedure that returns a `LIKE` quey!! Pin
PIEBALDconsult3-Dec-09 12:15
mvePIEBALDconsult3-Dec-09 12:15 
AnswerRe: Adding Parameter to a Stored Procedure that returns a `LIKE` query!! Pin
Minimech3-Dec-09 22:32
Minimech3-Dec-09 22:32 
Questionobject from treeview help needed Pin
BDJones3-Dec-09 10:02
BDJones3-Dec-09 10:02 
AnswerRe: object from treeview help needed Pin
Luc Pattyn3-Dec-09 10:10
sitebuilderLuc Pattyn3-Dec-09 10:10 
QuestionRe: object from treeview help needed Pin
BDJones3-Dec-09 10:24
BDJones3-Dec-09 10:24 
AnswerRe: object from treeview help needed Pin
Luc Pattyn3-Dec-09 10:33
sitebuilderLuc Pattyn3-Dec-09 10:33 
QuestionRe: object from treeview help needed Pin
BDJones3-Dec-09 10:48
BDJones3-Dec-09 10:48 
AnswerRe: object from treeview help needed Pin
Luc Pattyn3-Dec-09 11:20
sitebuilderLuc Pattyn3-Dec-09 11:20 
Hi,

sorry I was wrong (I use ListBox a lot, and TreeView very rarely).
In ComboBox and ListBox, you can add arbitrary types as items to the list, and what you see is its ToString result (unless OwnerDraw is in effect); however in a TreeView the items have to be TreeNode instances (the tree needs a standard way to find its branches and leaves, a ComboBox/ListBox doesn't have any hierarchy) and what you see is the TreeNode.Text

I see basically two ways to store more than just a string in a TreeView node:

1. create a TreeNode as you did, and store a reference to your object in the TreeNode.Tag property, which is there for you to use any way you like; you still have to provide a Text to the TreeNode (which you did), and if you want Find() to be successful, you should also set the Name property to the text value.

2. create a new class, say MyTreeNode, inheriting from TreeNode. You still need to explicitly set the Text property (as well as Name for a successful Find), but you no longer need to use Tag. As we don't have multiple inheritance nowadays, if you wanted to store say a Form in a tree (Form inherits from Control), you would have to use the first way (with Tag).

The main difference between both methods is the Tag indirection: the first item would be myTree.Nodes[0].Tag in (1) and myTree.Nodes[0] itself in (2)

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: object from treeview help needed Pin
BDJones3-Dec-09 11:40
BDJones3-Dec-09 11:40 
GeneralRe: object from treeview help needed Pin
Luc Pattyn3-Dec-09 11:43
sitebuilderLuc Pattyn3-Dec-09 11:43 
AnswerRe: object from treeview help needed Pin
puri keemti3-Dec-09 22:31
puri keemti3-Dec-09 22:31 
QuestionNon-Client Paint Issue Pin
notsotragichero3-Dec-09 9:12
notsotragichero3-Dec-09 9:12 
AnswerRe: Non-Client Paint Issue Pin
Natza Mitzi6-Dec-09 10:22
Natza Mitzi6-Dec-09 10:22 
QuestionWinforms HTML editor control? Pin
thechillhacker3-Dec-09 8:12
thechillhacker3-Dec-09 8:12 
AnswerRe: Winforms HTML editor control? Pin
Richard Blythe3-Dec-09 14:23
Richard Blythe3-Dec-09 14:23 
GeneralRe: Winforms HTML editor control? Pin
thechillhacker4-Dec-09 5:15
thechillhacker4-Dec-09 5:15 
GeneralRe: Winforms HTML editor control? Pin
Richard Blythe4-Dec-09 17:44
Richard Blythe4-Dec-09 17:44 
QuestionMaking one copy of complex type from 2 webservices. Pin
mittalpa3-Dec-09 6:46
mittalpa3-Dec-09 6:46 
AnswerRe: Making one copy of complex type from 2 webservices. Pin
Ashfield3-Dec-09 8:41
Ashfield3-Dec-09 8:41 
GeneralRe: Making one copy of complex type from 2 webservices. Pin
mittalpa3-Dec-09 11:19
mittalpa3-Dec-09 11:19 
QuestionHow to Close any opened Connections to a database? Pin
CoderForEver3-Dec-09 6:41
CoderForEver3-Dec-09 6:41 
AnswerRe: How to Close any opened Connections to a database? [modified] Pin
PIEBALDconsult3-Dec-09 7:51
mvePIEBALDconsult3-Dec-09 7:51 
GeneralRe: How to Close any opened Connections to a database? Pin
CoderForEver3-Dec-09 7:57
CoderForEver3-Dec-09 7:57 
GeneralRe: How to Close any opened Connections to a database? Pin
CoderForEver3-Dec-09 8:13
CoderForEver3-Dec-09 8:13 
AnswerRe: How to Close any opened Connections to a database? Pin
Shorgov3-Dec-09 11:17
Shorgov3-Dec-09 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.