H
Hrcko
How to get a list of items from listBox into array ?
Hrcko
Hrcko
You need to add each item in turn to an array or an ArrayList
object[] o = new object[listBox1.Items.Count];
for(int i = 0; i < o.Length; i++)
o = listBox1.Items;
Or ...
ArrayList list = new ArrayList();
foreach(object o in listBox1.Items)
list.Add(o);
You need to add each item in turn to an array or an ArrayList
object[] o = new object[listBox1.Items.Count];
for(int i = 0; i < o.Length; i++)
o = listBox1.Items;
Or ...
ArrayList list = new ArrayList();
foreach(object o in listBox1.Items)
list.Add(o);
If you don't want to write that much code, just create the ArrayList...
ArrayList a = new ArrayList( this.listBox1.Items );
Or if you wanted it as an array instead of an ArrayList...
Object[] a = new ArrayList( this.listBox1.Items ).ToArray();
// Bjorn A
I have a problem with this code because I
have a Guid in my listBox.
I can't convert System.Guid to Guid[].
Bjorn Abelli said:...
I have a problem with this code because I
have a Guid in my listBox.
I can't convert System.Guid to Guid[].
I think you possibly need to explain a little more what your problem is...
If you mean that you want a single Guid to appear in an array, well...
Lets say you have a System.Guid variable g...
System.Guid[] guidArray = {g};
..or were you referring to how to extract the elements of the listbox *as*
an array of Guid's?
Guid[] guidArray = (Guid[])
new ArrayList( this.listBox1.Items ).ToArray(typeof(Guid));
// Bjorn A
I need to put a list of Guids from listBox into Guid Array.
Bjorn Abelli said:...
I need to put a list of Guids from listBox into Guid Array.
So did you try the example I wrote?
Guid[] guidArray = (Guid[])
new ArrayList( this.listBox1.Items ).ToArray(typeof(Guid));
// Bjorn A
Now, I would like to chek if that array list is empty.
I want to display items that ARE NOT in my array list...
I wrote some code but I don't know how to exclude those items
nUserID is an array list.