1
Reply

Storing to an ArrayList or HashTable

Dave Abram

Dave Abram

Jun 14 2010 10:40 AM
4.1k

I have a Treeview with a combobox in which the user can make changes. I want to record the changes as they are made to an array or list of some sort so when the use hits the save button, it doesn't have to loop through all the nodes, but rather from an  array or list. I am not sure if I did this right, but here it is.
I started out by:
parentName =
this.tvdd_Navigation.SelectedNode.Parent.Text.Trim();
parentName = permissions +
","+ cleanIt(parentName);

I have to split some parts of the string so I used the following code and it did what I wanted it to do.

string[] strArray;
strArray = parentName.Split(
new char[] { ',' }); This shows the following:
[0] "0"
[1] "LatSec"
[2] "F"
[3] "9"

Now I need to store this to some kind of list, so I chose an ArrayList.
ArrayList myAL = new ArrayList();
myAL.AddRange(strArray);

This all works fine until they edit the second record. In doing so, it creates a new ArrayList (which only makes sense) and the first change is no longer there. How do I keep adding changes to the list without overriding the previous change?
Best regards,
Dave

Answers (1)