2
Answers

detail view in Listbox

prashant c

prashant c

15y
5k
1
I want to know how can i add contents in multiple columns in Listbox
just like in explore 1st column is file name & 2nd column is size,etc.
If possible please give me code too.
Answers (2)
0
Baimey Rajesh

Baimey Rajesh

NA 2.5k 128.3k 15y
A multicolumn list box places items into as many columns as are needed to make vertical scrolling unnecessary. The user can use the keyboard to navigate to columns that are not currently visible. Set the HorizontalScrollbar property to true to display a horizontal scroll bar that allows the user to scroll to columns that are not currently shown in the visible region of the ListBox. The value of the ColumnWidth property determines the width of each column. // Add items to the ListBox. for (int x = 0; x < 50; x++) { listBox1.Items.Add("Items " + x.ToString()); } // Display items in columns. listBox1.MultiColumn = true; // Determine the width of the items in the list to get the best column width setting. int width = (int) listBox1.CreateGraphics().MeasureString(listBox1.Items[listBox1.Items.Count -1].ToString(), listBox1.Font).Width; // Set the column width based on the width of each item in the list. listBox1.ColumnWidth = width; }
0
Baimey Rajesh

Baimey Rajesh

NA 2.5k 128.3k 15y
If you want multiple columns then switch to a ListView. It is basically a multi-column listbox with far superior support for doing what you want. listview1.Items.Add(new ListViewItem(new string[] { "Name", "Address" } );