Home All Groups Group Topic Archive Search About
Author
29 Mar 2005 2:39 PM
aaj
Hi all

I'm having a really stupid problem with listboxes

I have dropped a listbox on a form and I want to configure the columns

I just want a single column, but it seems that another blank one is created
by default to the right hand side

If I set the list box as width 150 and add a column

LSTProcessList.Columns.Add(New ColumnHeader)
LSTProcessList.Columns(0).Text = "Ref1"
LSTProcessList.Columns(0).Width = 150

Then I can grab the top of the column called Ref1, move it to the left and
there is a blank one to the right.

Is there any way that I can have one single column that scrolls up and down,
but not left and right.

thanks

Andy

Author
29 Mar 2005 2:54 PM
Cor Ligthert
AAJ,

A listbox has only one vertical column  or one vertical row (multicolomn).
Is that the problem?

I hope this helps,

Cor
Author
29 Mar 2005 2:55 PM
Bernie Yaeger
Hi Andy,

Listboxes in vb .net do not have a columns.add method.  Is this a custom
listbox?  A listview?

Bernie Yaeger

"aaj" <a**@aaj.com> wrote in message
news:1112107156.00d266e054768c3bdba721b5cc482828@teranews...
Show quoteHide quote
> Hi all
>
> I'm having a really stupid problem with listboxes
>
> I have dropped a listbox on a form and I want to configure the columns
>
> I just want a single column, but it seems that another blank one is
> created by default to the right hand side
>
> If I set the list box as width 150 and add a column
>
> LSTProcessList.Columns.Add(New ColumnHeader)
> LSTProcessList.Columns(0).Text = "Ref1"
> LSTProcessList.Columns(0).Width = 150
>
> Then I can grab the top of the column called Ref1, move it to the left and
> there is a blank one to the right.
>
> Is there any way that I can have one single column that scrolls up and
> down, but not left and right.
>
> thanks
>
> Andy
>
>
>
>
Author
29 Mar 2005 3:14 PM
aaj
sorry, meant list view :)

Show quoteHide quote
"Bernie Yaeger" <bern***@cherwellinc.com> wrote in message
news:u3v2K9GNFHA.1176@TK2MSFTNGP15.phx.gbl...
> Hi Andy,
>
> Listboxes in vb .net do not have a columns.add method.  Is this a custom
> listbox?  A listview?
>
> Bernie Yaeger
>
> "aaj" <a**@aaj.com> wrote in message
> news:1112107156.00d266e054768c3bdba721b5cc482828@teranews...
>> Hi all
>>
>> I'm having a really stupid problem with listboxes
>>
>> I have dropped a listbox on a form and I want to configure the columns
>>
>> I just want a single column, but it seems that another blank one is
>> created by default to the right hand side
>>
>> If I set the list box as width 150 and add a column
>>
>> LSTProcessList.Columns.Add(New ColumnHeader)
>> LSTProcessList.Columns(0).Text = "Ref1"
>> LSTProcessList.Columns(0).Width = 150
>>
>> Then I can grab the top of the column called Ref1, move it to the left
>> and there is a blank one to the right.
>>
>> Is there any way that I can have one single column that scrolls up and
>> down, but not left and right.
>>
>> thanks
>>
>> Andy
>>
>>
>>
>>
>
>
Author
29 Mar 2005 11:07 PM
J L
If your question is how to make the listview size fit the data
exactly, you can do this as follows

intLVWWidth = 0   <--- this will be the final width we want the
listview to be once we size the columns to the data.

for i = 0 to lstView.Columns.Count - 1
   lstView.Columns(i).Width = -2     <--- this forces col to fit data
   intLVWWidth += lstView.Columns(i).Width
next
intLVWWidth += SystemInformation.Border3DSize.Width * 2 +
   SystemInformation.VerticalScrollBarWidth
lstView.Width = intLVWWidth

This will eliminate the space on the right and fit every thing
perfectly. A refinement is to be sure that the column heading is not
larger than any of the data. To do this, in the loop, you can look at
the lstView.Columns(i).Width = -1 value. That sizes the column to the
header. If it is greater than the data width, then use it.

Thanks goes to someone on this NG for sharing this with me. I thought
it was neat. Hope it is what you are looking for.

John


Show quoteHide quote
On Tue, 29 Mar 2005 16:14:45 +0100, "aaj" <a**@aaj.com> wrote:

>sorry, meant list view :)
>
>"Bernie Yaeger" <bern***@cherwellinc.com> wrote in message
>news:u3v2K9GNFHA.1176@TK2MSFTNGP15.phx.gbl...
>> Hi Andy,
>>
>> Listboxes in vb .net do not have a columns.add method.  Is this a custom
>> listbox?  A listview?
>>
>> Bernie Yaeger
>>
>> "aaj" <a**@aaj.com> wrote in message
>> news:1112107156.00d266e054768c3bdba721b5cc482828@teranews...
>>> Hi all
>>>
>>> I'm having a really stupid problem with listboxes
>>>
>>> I have dropped a listbox on a form and I want to configure the columns
>>>
>>> I just want a single column, but it seems that another blank one is
>>> created by default to the right hand side
>>>
>>> If I set the list box as width 150 and add a column
>>>
>>> LSTProcessList.Columns.Add(New ColumnHeader)
>>> LSTProcessList.Columns(0).Text = "Ref1"
>>> LSTProcessList.Columns(0).Width = 150
>>>
>>> Then I can grab the top of the column called Ref1, move it to the left
>>> and there is a blank one to the right.
>>>
>>> Is there any way that I can have one single column that scrolls up and
>>> down, but not left and right.
>>>
>>> thanks
>>>
>>> Andy
>>>
>>>
>>>
>>>
>>
>>
>
Author
29 Mar 2005 11:11 PM
J L
Aha....credit for my last post goes to Tim Wilson on the Window Froms
Control list. Thanks Tim!

John

Show quoteHide quote
On Tue, 29 Mar 2005 16:14:45 +0100, "aaj" <a**@aaj.com> wrote:

>sorry, meant list view :)
>
>"Bernie Yaeger" <bern***@cherwellinc.com> wrote in message
>news:u3v2K9GNFHA.1176@TK2MSFTNGP15.phx.gbl...
>> Hi Andy,
>>
>> Listboxes in vb .net do not have a columns.add method.  Is this a custom
>> listbox?  A listview?
>>
>> Bernie Yaeger
>>
>> "aaj" <a**@aaj.com> wrote in message
>> news:1112107156.00d266e054768c3bdba721b5cc482828@teranews...
>>> Hi all
>>>
>>> I'm having a really stupid problem with listboxes
>>>
>>> I have dropped a listbox on a form and I want to configure the columns
>>>
>>> I just want a single column, but it seems that another blank one is
>>> created by default to the right hand side
>>>
>>> If I set the list box as width 150 and add a column
>>>
>>> LSTProcessList.Columns.Add(New ColumnHeader)
>>> LSTProcessList.Columns(0).Text = "Ref1"
>>> LSTProcessList.Columns(0).Width = 150
>>>
>>> Then I can grab the top of the column called Ref1, move it to the left
>>> and there is a blank one to the right.
>>>
>>> Is there any way that I can have one single column that scrolls up and
>>> down, but not left and right.
>>>
>>> thanks
>>>
>>> Andy
>>>
>>>
>>>
>>>
>>
>>
>
Author
30 Mar 2005 7:02 AM
aaj
Thanks to all who replied. I will give it ago today

cheers

Andy


Show quoteHide quote
"J L" <j***@marymonte.com> wrote in message
news:s2oj415e0lmek01omckhbb7nijv9n1uo1f@4ax.com...
>
> Aha....credit for my last post goes to Tim Wilson on the Window Froms
> Control list. Thanks Tim!
>
> John
>
> On Tue, 29 Mar 2005 16:14:45 +0100, "aaj" <a**@aaj.com> wrote:
>
>>sorry, meant list view :)
>>
>>"Bernie Yaeger" <bern***@cherwellinc.com> wrote in message
>>news:u3v2K9GNFHA.1176@TK2MSFTNGP15.phx.gbl...
>>> Hi Andy,
>>>
>>> Listboxes in vb .net do not have a columns.add method.  Is this a custom
>>> listbox?  A listview?
>>>
>>> Bernie Yaeger
>>>
>>> "aaj" <a**@aaj.com> wrote in message
>>> news:1112107156.00d266e054768c3bdba721b5cc482828@teranews...
>>>> Hi all
>>>>
>>>> I'm having a really stupid problem with listboxes
>>>>
>>>> I have dropped a listbox on a form and I want to configure the columns
>>>>
>>>> I just want a single column, but it seems that another blank one is
>>>> created by default to the right hand side
>>>>
>>>> If I set the list box as width 150 and add a column
>>>>
>>>> LSTProcessList.Columns.Add(New ColumnHeader)
>>>> LSTProcessList.Columns(0).Text = "Ref1"
>>>> LSTProcessList.Columns(0).Width = 150
>>>>
>>>> Then I can grab the top of the column called Ref1, move it to the left
>>>> and there is a blank one to the right.
>>>>
>>>> Is there any way that I can have one single column that scrolls up and
>>>> down, but not left and right.
>>>>
>>>> thanks
>>>>
>>>> Andy
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
Author
29 Mar 2005 4:19 PM
Herfried K. Wagner [MVP]
"aaj" <a**@aaj.com> schrieb:
> I'm having a really stupid problem with listboxes

I assume you are talking about a listview control...

> I have dropped a listbox on a form and I want to configure the columns
>
> I just want a single column, but it seems that another blank one is
> created by default to the right hand side
>
> If I set the list box as width 150 and add a column
>
> LSTProcessList.Columns.Add(New ColumnHeader)
> LSTProcessList.Columns(0).Text = "Ref1"
> LSTProcessList.Columns(0).Width = 150
>
> Then I can grab the top of the column called Ref1, move it to the left and
> there is a blank one to the right.

If the column doesn't fill the whole horizontal space of the listview
control, the header bar will fill the rest of the space.

> Is there any way that I can have one single column that scrolls up and
> down, but not left and right.

Set the column's width to the width of the listview's client size.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>