Multi Column Listbox

2019-07-15 11:14发布

问题:

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

回答1:

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.



回答2:

For .NET 2.0 you can use the UseCustomTabOffsets and CustomTabOffsets, if you need multi-column support in your ListBox. See how to make more than 2 column's in ListBox using C#? for an example of use.