Any thoughts on a clean way to modify an extant (and otherwise "ordinary") listBox such that it has more than one column? Further, once so altered, how to populate said listBox?

example:
listBox1.MultiColumn = true;

...

now, I'm stuck! :(

Use a listview, or grid??

I usually use DatGridViews which are easy enough. I've always used list boxes in their single column mode (listbox.items.add). I wanted to try the same thing with multiple columns - but all the literature I've read on the subject makes it all not even as clear as mud.

Listviews are rather dumb. In the help it shows adding an array of text:

this.listBox1.Items.AddRange(new object[] {
              "Item 1, column 1",
              "Item 2, column 1",
              "Item 3, column 1",
              "Item 4, column 1",
              "Item 5, column 1",
              "Item 1, column 2",
              "Item 2, column 2",
              "Item 3, column 2"});

The stupid thing works because the default vertical size will cause a rollover at Item 1/col 2. Shift the height and you shift the lists that line up with each other.

Listviews are rather dumb. In the help it shows adding an array of text:
...clipped code
The stupid thing works because the default vertical size will cause a rollover at Item 1/col 2. Shift the height and you shift the lists that line up with each other.

I take it back. It's not dumb, it has a misleading property name and a misleading message in help. If the help was a little clearer, it might say
"The MultiColumn property, when true will cause the ListBox to scroll horizontally instead of vertically when the list is longer than the window can show."
The way it is, I too, thought this was a way to format a multicolum object like a DataRow when I first read it. I think a boolian property like "HorizontalScroll" would have a more intuitive meaning to it. No changing it now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.