Multicolumn Listbox

W

WRH

Hello
I want to have a multicolumn listbox. I never used one before
so I looked at a Help example. I set the multicolumn property and
the column width and tested with this example...

this.listBox3.Items.AddRange(new object[]
{
"Item 1, column 1",
"Item 2, column 1",
"Item 3, column 1",
"Item 4, column 1",
"Item 5, column 1",
"Item 1, column 2",
"Item 2, column 2",
"Item 3, column 2" });

It works perfectly, with column 1 items is column one and column 2
items in column 2. Now here's why I posted...I don't understand the
example! What is there that results in a two column list with 5 lines
in column 1 and 3 lines in column 2?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Each object is a comma separated list of values so I assume that the listbox
expect that you define the columns that way.

You failed to mention if this is a web or a win example ( I assume that a
window)
 
W

WRH

Thanks for the quick reply.
Further testing shows that the last 3 items went into column 2 only
because of the height of the listBox (No vertical scroll) What I want
is to specify the column for an item.

Using windows forms, MS VC# 2005 express edition


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Each object is a comma separated list of values so I assume that the
listbox expect that you define the columns that way.

You failed to mention if this is a web or a win example ( I assume that a
window)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
WRH said:
Hello
I want to have a multicolumn listbox. I never used one before
so I looked at a Help example. I set the multicolumn property and
the column width and tested with this example...

this.listBox3.Items.AddRange(new object[]
{
"Item 1, column 1",
"Item 2, column 1",
"Item 3, column 1",
"Item 4, column 1",
"Item 5, column 1",
"Item 1, column 2",
"Item 2, column 2",
"Item 3, column 2" });

It works perfectly, with column 1 items is column one and column 2
items in column 2. Now here's why I posted...I don't understand the
example! What is there that results in a two column list with 5 lines
in column 1 and 3 lines in column 2?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You have to read the docs and see what format ListBox expect for
multicolumns lists.

I just found the txt:
A multicolumn ListBox 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
enables 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.



--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
WRH said:
Thanks for the quick reply.
Further testing shows that the last 3 items went into column 2 only
because of the height of the listBox (No vertical scroll) What I want
is to specify the column for an item.

Using windows forms, MS VC# 2005 express edition


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Each object is a comma separated list of values so I assume that the
listbox expect that you define the columns that way.

You failed to mention if this is a web or a win example ( I assume that a
window)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
WRH said:
Hello
I want to have a multicolumn listbox. I never used one before
so I looked at a Help example. I set the multicolumn property and
the column width and tested with this example...

this.listBox3.Items.AddRange(new object[]
{
"Item 1, column 1",
"Item 2, column 1",
"Item 3, column 1",
"Item 4, column 1",
"Item 5, column 1",
"Item 1, column 2",
"Item 2, column 2",
"Item 3, column 2" });

It works perfectly, with column 1 items is column one and column 2
items in column 2. Now here's why I posted...I don't understand the
example! What is there that results in a two column list with 5 lines
in column 1 and 3 lines in column 2?
 
W

WRH

Thanks again for the info.

I have decided to use ListView instead, as it seems much
more manageable with regard to columns.

I could not be sure what the user may see at any given
time with a multicolumn ListBox!

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

You have to read the docs and see what format ListBox expect for
multicolumns lists.

I just found the txt:
A multicolumn ListBox 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 enables 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.



--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
WRH said:
Thanks for the quick reply.
Further testing shows that the last 3 items went into column 2 only
because of the height of the listBox (No vertical scroll) What I want
is to specify the column for an item.

Using windows forms, MS VC# 2005 express edition


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Each object is a comma separated list of values so I assume that the
listbox expect that you define the columns that way.

You failed to mention if this is a web or a win example ( I assume that
a window)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Hello
I want to have a multicolumn listbox. I never used one before
so I looked at a Help example. I set the multicolumn property and
the column width and tested with this example...

this.listBox3.Items.AddRange(new object[]
{
"Item 1, column 1",
"Item 2, column 1",
"Item 3, column 1",
"Item 4, column 1",
"Item 5, column 1",
"Item 1, column 2",
"Item 2, column 2",
"Item 3, column 2" });

It works perfectly, with column 1 items is column one and column 2
items in column 2. Now here's why I posted...I don't understand the
example! What is there that results in a two column list with 5 lines
in column 1 and 3 lines in column 2?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
WRH said:
Thanks again for the info.

I have decided to use ListView instead, as it seems much
more manageable with regard to columns.

I could not be sure what the user may see at any given
time with a multicolumn ListBox!

Wise decision, Listview is the control for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top