|
-
Sep 23rd, 2012, 01:10 AM
#2
Re: Array used in listboxes?
What do you mean "an array with 5 rows 3 columns"? An array is not a DataTable, although to visualize multi-dimensional arrays, it may be easier to picture it that way. I don't get what you're trying to do. Why don't you just do this if you want to add "A" to "E" in one ListBox and "1" to "3" in the other:
csharp Code:
listBox1.Items.AddRange("ABCDEFG".Select(c => c.ToString()).ToArray());
listBox2.Items.AddRange(Enumerable.Range(1, 3).Select(i => i.ToString()).ToArray());
If you're meaning to add "A1", "A2", "A3", "B1", "B2", etc... to one Listbox, and "1A", "2A", 3A", ect... to the other Listbox. Then:
csharp Code:
string s = "ABCDEFG";
string nums = "123";
var x1 = (from char c in s
from char n in nums
select string.Format("{0}{1}", c, n)).ToArray();
var x2 = (from char c in s
from char n in nums
select string.Format("{0}{1}", n, c)).ToArray();
listBox1.Items.AddRange(x1);
listBox2.Items.AddRange(x2);
Last edited by AceInfinity; Sep 23rd, 2012 at 01:19 AM.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|