Solved

List View cell size limit?

Posted on 1998-07-22
3
356 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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