How to change column width in ListView control in lvwList mode 
Author Message
 How to change column width in ListView control in lvwList mode

I'm using mscomctl.ocx from vb6 sp5.  As per the Platform SDK documentation,
under LVM_SETCOLUMNWIDTH

        lResult = SendMessage(               // returns LRESULT in lResult
        (HWND) hWndControl,                  // handle to destination
control
        (UINT) LVM_SETCOLUMNWIDTH,           // message ID
        (WPARAM) wParam,                     // = (WPARAM) (int) iCol
        (LPARAM) lParam                      // = (LPARAM) MAKELPARAM ((int)
cx, 0)
        );

iCol
Zero-based index of a valid column. For list-view mode, this parameter must
be set to zero.
Return Value
Returns TRUE if successful, or FALSE otherwise.
This references the commctrl.h header file which I used to get the constants
to import into my project.
Code fragment:

Private Function SetColumnWidth(lNewTwipWidth) As Long

Const LVM_FIRST = &H1000
Const LVM_GETCOLUMNWIDTH = LVM_FIRST + 29
Const LVM_SETCOLUMNWIDTH = LVM_FIRST + 30

Dim lNewPixelWidth

lNewPixelWidth = lNewTwipWidth / (Screen.TwipsPerPixelX)
SetColumnWidth = SendMessage(ListView1.hwnd, LVM_SETCOLUMNWIDTH, 0,
lNewPixelWidth)

End Function

This does in fact return 1 indicating success.  Unfortunately when I call
this it blanks out the ListView control so that nothing is displayed in it.
All the data is there - I can retrieve, set, add ListItem entries etc, but
nothing displays :-(  I tried doing a .Refresh thinking I just needed a
Paint, but that didn't help.  Any ideas?

Thanks!



Fri, 21 Oct 2005 05:37:41 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Column Width in List mode (Listview control)

2. ListView column width = ListView width ?

3. change the column width in Crystal Report in preview mode

4. PRB: How to Change column width of ListView control using view style 'lvwList'

5. Event needed for changing width of ListView column

6. how to change the width of column in listview by programming

7. ListView Control: Setting width of ListItems in list mode

8. Total width of columns = Width of ListView

9. Total width of columns = Width of ListView

10. Total width of columns = Width of ListView

11. Total width of columns = Width of ListView

12. How to get control if you resize the width of a Column in a ListView

 

 
Powered by phpBB® Forum Software