Link to home
Start Free TrialLog in
Avatar of ba272
ba272

asked on

Generating a ToString() value for a multi-column listbox.

Hi,

How do I separate the columns, in the ToString() return value?  The tab? '\t'?

Thanks.
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

ToString() return value for which object?
Avatar of ba272
ba272

ASKER

I add objects to a listbox, and the ToString() method for that object is called to provide the string to display for that object.  That's the standard way to add an object to a listbox - you override ToString(), and whatever that object returns for ToStiring() will be displayed in the listbox.

My question is about multiple column listboxes.  What character is used to diferentiate the columns?
Avatar of ba272

ASKER

The answer is that Yes, it's the tab key which distinguishes one column from the next.
Avatar of ba272

ASKER

I wasn't expecting it to be so easy.
Listbox has a property multicolumn in it. However that does not allow seperate multiple lists of items to be displayed in multiple columns. Setting this bool property has the effect of overflow items displayed in columns aligned next to each other with a horzonital scroll bar instead of in a single list with a vertical scroll bar.

To have "seperate" multiple columns use listview or the datagrid classes.
System.Windows.Forms.DataGrid

System.Windows.Forms.ListView
ASKER CERTIFIED SOLUTION
Avatar of mcv22
mcv22
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ba272

ASKER

Yes, that is sweet!  Thanks.