473,769 Members | 5,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_SETCOLUMNWI DTH As Long = &H101E
Const LVM_SETEXTENDED LISTVIEWSTYLE 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 "SendMessag eA" ( _
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.ListI tems.Clear

For i = 0 To 100

With ListView1.ListI tems.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(Lis tView1.hWnd, LVM_SETCOLUMNWI DTH, 1, ByVal
LVSCW_AUTOSIZE_ USEHEADER)
Call SendMessage(Lis tView1.hWnd, LVM_SETCOLUMNWI DTH, 2, ByVal
LVSCW_AUTOSIZE)
End Sub

Private Sub Form_Load()
ListView1.View = lvwReport
Call ListView1.Colum nHeaders.Add(, , "Column 1")
Call ListView1.Colum nHeaders.Add(, , "Column 2")
Call ListView1.Colum nHeaders.Add(, , "Column 3")
Call SendMessage( _
ListView1.hWnd, LVM_SETEXTENDED LISTVIEWSTYLE, 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 10390
"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.publi c.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*******@free net.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*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
VB5 is dead. This is a group about VB.Net (see group name).
microsoft.publi c.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**********@p lanet.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.m icrosoft.com> wrote in message
news:4m******** ******@cpmsftng xa10.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.m icrosoft.com> wrote in message
news:OO******** ******@cpmsftng xa10.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
3506
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 -------------------------------------------------------------- RCSOFT, Lda.
0
1740
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 System.Windows.Forms.ColumnClickEventArgs) Handles ListView.ColumnClick If ListView.Sorting = System.Windows.Forms.SortOrder.Ascending Then ListView.Sorting = System.Windows.Forms.SortOrder.Descending Else ListView.Sorting = System.Windows.Forms.SortOrder.Ascending
6
4659
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(); listView1.Items.Add (myString); } Is there a way I can fill up the second column this easily? Thw way I'm currently doing it is using the subitems property to add it. Unfortunately,
1
7360
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(); MyColumnHeader.Text = "col1"; MyColumnHeader.Width = -2; // if you remove this line col appears MyListView.Columns.Add(MyColumnHeader);
1
2412
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
7486
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 the overall size of the listview. My question therefore is, how can I tell if the items I have added will fit in the listview at its given height? A secondary one, just for interest sake...is there a way to determine the exact heght needed...
2
2309
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 like this? -- | +-- Thief_ |
1
2126
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 stored in LargeImageList) but the only way I can see to tell the listview how large I want each thumb to be is by setting the ImageSize property of LargeImageList. Unfortunately, the maximum size for an image in this case is 256 x 256 pixels, but...
0
1116
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 on with the sorting property. You are much better off rolling your own to take account of the different data types the LV may contain, you can also use it to set the sort icons.
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.