|
-
September 7th, 2004, 06:14 AM
#1
MutliColumn Listbox
How on earth do you added data to the different columns of a multi column Listbox?
Any example would help as I can't find any anywhere
-
September 8th, 2004, 08:08 AM
#2
Re: MutliColumn Listbox
A multi column list box has no vertical scroll bar.
When a new item is added which would normally cause a vertical scroll bar to appear, it is instead inserted into a new column to the right.
Try this : it's from MSDN and demonstrates the behaviour very well.
Code:
// Add items to the ListBox.
for (int x = 0; x < 50; x++)
{
listBox1.Items.Add(string.Format("Items {0}", x));
}
// 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;
If you don't want behaviour like this then use a ListView in report mode instead.
Darwen.
Last edited by darwen; September 8th, 2004 at 08:13 AM.
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
|