Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body :)

First of all, my thanks to all the people who helped me out earlier.

I have a small query.

In my form I have two panes. The left hand pane is a Treeview and the right hand pane is a collection of common controls such as textboxes, checkboxes, labels etc.

As I navigate through each node of the treeview I need to populate the controls on the right hand side of the form

The values with which I need to populate the controls are in the tags of the treeview nodes.

Now I am going to store values in the tags delimited by a '|' or a ';'

I will be using stringvar.split() to create an array of strings.

Is there any way for me to create a routine to store the individual arrays created by the split() method into the controls on the right hand pane.
C#
char[] delimiterChars = { '|' };

string text = "This|is|some|text";
string[] words = text.Split(delimiterChars);

foreach (string s in words)
{
   // Do something
}

I just need some guidance on how to store the individual strings into the controls, without the code getting messy

I have restarted programming in C# after 4 years

Would appreciate any help :-D

Have a great Day!
Posted
Updated 20-Aug-10 1:03am
v2

1 solution

From what I do understand, you should think again, whether your decision to store strings in the tag is really that good.

In my projects, I do store full objects in the TreeNode.Tag[^] property.

This way, you could put the values in properties of my own class, create an instance of this class and asign it to the Tag property.

When reading, simply cast the values of the Tag property back to your original object.

Much easier and safer than your string parsing idea, in my opinion :-)
 
Share this answer
 
Comments
RebornDeveloper 19-Aug-10 15:46pm    
Hi,

Many thanks for your reply

So, I do the following

1. Store the object in the Node's Tag value.

2. Later when I need to access the properties in the object I simply create a new object of the class in question and cast the value in the treenode tag to that object

3. Access the properties of that object.

Right?

Also, can I store two objects together into the tag as strings?

Is there any way for me to convert these two objects stored as strings, back into separate objects?

Thanks a ton
Reborndeveloper

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900