Solved

List View cell size limit?

Posted on 1998-07-22
3
353 Views
Last Modified: 2012-05-04
Is there a limit to the number of characters a list view cell can display? It appears the limit is 255?
0
Comment
Question by:rascal
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1168383
Try using the ListView_GetStringWidth() and ListView_SetColumnWidth() macros.


The ListView_GetStringWidth macro determines the width of a specified string, using the specified list view control's current font. You can use this macro or explicitly send the LVM_GETSTRINGWIDTH message.

int ListView_GetStringWidth(
    HWND hwnd,       
    LPCSTR psz      
   );      
 
Parameters
hwnd - Handle to the list view control.
psz - Pointer to a null-terminated string.
 
Return Values - Returns the string width if successful or zero otherwise.


The ListView_SetColumnWidth macro changes the width of a column in report or list view. You can use this macro or explicitly send the LVM_SETCOLUMNWIDTH message.
BOOL ListView_SetColumnWidth(
    HWND hwnd,       
    int iCol,       
    int cx      
   );      
 
Parameters
hwnd - Handle to the list view control.
iCol - Index of the column. In list view, the iCol parameter must be -1.
cx - New width of the column, in list view coordinates, or one of the following values:
LVSCW_AUTOSIZE - Automatically sizes the column.
LVSCW_AUTOSIZE_USEHEADER - Automatically sizes the column to fit the header text.

0
 
LVL 1

Author Comment

by:rascal
ID: 1168384
Thanks, but I need to know if there is an upper limit that the column display. I will try the sample code you provided with various length strings but I need to know if there is an explicit upper boundary of length a list view column can support. Thanks again.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168385
Actually, there is a limit because the argument to LVM_SETCOLUMNWIDTH is a positive WORD.  Thus the limit is 32K pixels.  The number of characters depends on the font.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now