473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Autosize Limits on ListView Column Sizes

Can anyone confirm whether or not there are any limits imposed on the widths
of autosized columns in a list-view. I've found that the autosizing appears
to have an upper limit, i.e. it will not expand beyond some (unknown)
maximum length. This applies to user-autosizing (double-clicking the
divider) and code-autosizing using LVSCW_AUTOSIZE.

For example, create a new project and place a ListView (VB5 version) and
CommandButton on a form and insert the following code:

Const LVM_SETCOLUMNWIDTH As Long = &H101E
Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = &H1036
Const LVS_EX_LABELTIP As Long = &H4000
Const LVSCW_AUTOSIZE As Long = &HFFFFFFFF
Const LVSCW_AUTOSIZE_USEHEADER As Long = &HFFFFFFFE

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

Private Sub Command1_Click()
Dim i As Long

Call ListView1.ListItems.Clear

For i = 0 To 100

With ListView1.ListItems.Add(, , String$(300, AscW(CStr(i))))
.SubItems(1) = String$(300, AscW(CStr(i)))
.SubItems(2) = String$(300, AscW(CStr(i)))
End With

Next

Call SendMessage(ListView1.hWnd, LVM_SETCOLUMNWIDTH, 1, ByVal
LVSCW_AUTOSIZE_USEHEADER)
Call SendMessage(ListView1.hWnd, LVM_SETCOLUMNWIDTH, 2, ByVal
LVSCW_AUTOSIZE)
End Sub

Private Sub Form_Load()
ListView1.View = lvwReport
Call ListView1.ColumnHeaders.Add(, , "Column 1")
Call ListView1.ColumnHeaders.Add(, , "Column 2")
Call ListView1.ColumnHeaders.Add(, , "Column 3")
Call SendMessage( _
ListView1.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_LABELTIP, ByVal
LVS_EX_LABELTIP)
End Sub

I've noticed the following:

1. "Column 3" does not completely autosize, it stops short of the full range
of characters and also does not apply trailing ellipsis. The limit seems to
be 260 chars (259 chars + null terminator), however this only applies to
"drawing" the text since the tooltip indicates that the full text is
correctly stored in the list-view.
2. "Column 2" does not autosize to the header, LVSCW_AUTOSIZE_USEHEADER
seems to be working like LVSCW_AUTOSIZE here (note that it is not the last
column, hence it should really autosize to the column header).
3. Double-clicking the divider to the right of "Column 1" produces the same
results for "Column 1" as 1. does for "Column 3."

Is this behaviour intentional? I could understand the limits to autosizing
columns based on the fact that true autosizing could get crazy for columns
containing large amounts of text, however there's nothing documented in
MSDN. The clipped text seems like a drawing bug to me, maybe related to
using a MAX_PATH sized buffer for drawing?

--
Kevin Westhead
Nov 20 '05 #1
9 10330
"Kevin Westhead" <ke****@NOSPAM.i2DOTcoDOTuk> schrieb
Can anyone confirm whether or not there are any limits imposed on the
widths of autosized columns in a list-view. I've found that the
autosizing appears to have an upper limit, i.e. it will not expand
beyond some (unknown) maximum length. This applies to user-autosizing
(double-clicking the divider) and code-autosizing using
LVSCW_AUTOSIZE.

For example, create a new project and place a ListView (VB5 version)
and CommandButton on a form and insert the following code:


VB5 is dead. This is a group about VB.Net (see group name).
microsoft.public.vb.* deals with older verions.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "Armin Zingler" <az*******@freenet.de> scripsit:
Can anyone confirm whether or not there are any limits imposed on the
widths of autosized columns in a list-view. I've found that the
autosizing appears to have an upper limit, i.e. it will not expand
beyond some (unknown) maximum length. This applies to user-autosizing
(double-clicking the divider) and code-autosizing using
LVSCW_AUTOSIZE.

For example, create a new project and place a ListView (VB5 version)
and CommandButton on a form and insert the following code:


VB5 is dead.


Only in this group, but there are other groups where it's still alive
;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
> > VB5 is dead.

Only in this group, but there are other groups where it's still alive
;-).


And?
Nov 20 '05 #4
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
VB5 is dead. This is a group about VB.Net (see group name).
microsoft.public.vb.* deals with older verions.


You're right (about the newsgroup), I absent mindedly posted to the wrong
group - sorry.

Having said that, a quick test with a WinForms list-view shows that the same
problem occurs, so it's most likely a problem with the underlying common
control rather than any language-specific issue.

--
Kevin Westhead
Nov 20 '05 #5
* "Cor Ligthert" <no**********@planet.nl> scripsit:
VB5 is dead.


Only in this group, but there are other groups where it's still alive
;-).


And?


.... nothing!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
Hi Kevin,

I think you may try to take a look at the link below, is that what are you
looking for? If you still have any concern on this issue, please feel free
to post here.

SYMPTOMS
When you add long strings to a ListView control, all of the string is added
to the items collection, but the control can only display the first 259
characters of each item.

PRB: ListView Control Can Only Display 259 Characters per Column (321104)
http://support.microsoft.com/default...B;EN-US;321104

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:4m**************@cpmsftngxa10.phx.gbl...
SYMPTOMS
When you add long strings to a ListView control, all of the string is added to the items collection, but the control can only display the first 259
characters of each item.

PRB: ListView Control Can Only Display 259 Characters per Column (321104)
http://support.microsoft.com/default...B;EN-US;321104

Thanks Peter.

Can you explain why this is by design, i.e. why does a limit exist for
displaying an item's text but there is no limit for the actual item text
stored with the item? Is it performance related? I take it then that the
autosizing algorithm uses the displayed string then?

--
Kevin Westhead
Nov 20 '05 #8
Hi Kevin,

Thank you for your response.
Why the length of the text of listview item is limited to 259 character is
because that the listview is design for display collection of objects like
files and not for general purpose control. So it is similar to the filename
length limitation in the windows file system's MAX_PATH.

Hope this helps.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #9
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:OO**************@cpmsftngxa10.phx.gbl...
Why the length of the text of listview item is limited to 259 character is
because that the listview is design for display collection of objects like
files and not for general purpose control. So it is similar to the filename length limitation in the windows file system's MAX_PATH.

Okay, thanks. It seems like it would still be a good idea to use trailing
ellipsis when drawing the text for items that have text > 259 characters.

--
Kevin Westhead
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
How I can autosize a DataGrid after then associate a Datasource=Dataset in Smart Devices applications or Windows forms application?? That same?? -- Cumprimentos, David de Passos...
0
by: rmorvay | last post by:
I have successfully integrated sorting in the listview control with the following code: Private Sub ListView_ColumnClick(ByVal sender As Object, ByVal e As...
6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
1
by: Cybertof | last post by:
Hello, Do you know why in the following code the result is a column of size 0 ? (in the doc it says to use -2 to autosize column header...) ColumnHeader MyColumnHeader = new ColumnHeader();...
1
by: cody | last post by:
How can I prevent column autosizing on doubleclick on columnheader in a ListView? -- cody Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
2
by: Thief_ | last post by:
Does the VB Listview have some sort of event which fires when the user resizes the columns in Details view? I want to record the column sizes as the user changes them. If not, can I create an event...
1
by: Duracel | last post by:
Hi (this is a rephrase of my question from yesterday!), How can I set the size of the thumbnails of a listview in thumbnail mode? I'm owner drawing images from my own cache (i.e. they aren't...
0
by: Jeff Gaines | last post by:
On 29/08/2008 in message <F58652AE-D036-4EF5-8078-36A60D90D0F3@microsoft.comEd Kramer wrote: There is a crude in-built sorter which will sort column 1 either ascending or descending - turn it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.