views:

1934

answers:

3

Hi, Is there a way to bind a Generic List to a multicolumn listbox, yes listbox...I know but this is what I am stuck with and can't add a grid or listview.

Thanks

+3  A: 

You could bind a list to a listbox like this:

List<int> list = new List<int> { 1, 2, 4, 8, 16 };
listBox1.DataSource = list;

As for multicolumn listbox documentation says ListBox.MultiColumn only places items into as many columns as are needed to make vertical scrolling unnecessary.

If you want to show several columns of information for which an entire row will get selected you could use Multi Column List Box by Chris Rickard.

Alexander Prokofyev
A: 

Can I ask: what is the restriction? Why can't you use a ListView?

I'll strike the rest, in deference to Alexander's excellent answer: Not as far as I know; you'd probably need to just come up with some way of formatting a single column of text to look good enough...

Marc Gravell
A: 

For .NET 2.0 you can use the UseCustomTabOffsets and CustomTabOffsets, if you need multi-column support in your ListBox. See http://stackoverflow.com/questions/1365973/how-to-make-more-than-2-columns-in-listbox-using-c/1372212#1372212 for an example of use.

AMissico