ListView(List Mode) SetColumnWidth does not work 
Author Message
 ListView(List Mode) SetColumnWidth does not work

I need to get a list mode ListView to not truncate any entries (i.e. set
column width to the max required data size).  I've exhausted my list of
resources (MSDN, VBNet, DejaNews...) to no avail.  The following code works
if the LV is in Report mode but not in List mode (contrary to the twice
amended SetColumnWidth doc), although the equivalent works as expected in
VC++

Who can help?

Cheers,
Derek.

Private Sub Command1_Click()

    Dim b As Boolean

    Dim i As Integer
    For i = 1 To 20
        lv5.ListItems.Add , , "Really long item, so long it truncates"
        lv6.ListItems.Add , , "Really long item, so long it truncates"
    Next i

    b = ListView_SetColumnWidth(lv5.hWnd, 0, 400) 'LVSCW_AUTOSIZE)
    b = ListView_SetColumnWidth(lv6.hWnd, 0, 400) 'LVSCW_AUTOSIZE)
End Sub



Fri, 05 Apr 2002 03:00:00 GMT  
 ListView(List Mode) SetColumnWidth does not work
Will this do the trick ?

  Const LVSCW_AUTOSIZE = -1
  Const LVSCW_AUTOSIZE_USEHEADER = -2
  Const LVM_FIRST = &H1000
  Const LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30)

Private Sub Command1_Click()

  Dim b As Boolean
  Dim i As Integer

  lv.View = lvwReport

  For i = 1 To 20

    lv.ListItems.Add , , "Really long item, so long it truncates"

  Next i

  Call SendMessage(lv.hwnd, _
                    LVM_SETCOLUMNWIDTH, _
                    0&, LVSCW_AUTOSIZE)
  lv.View = lvwList

End Sub

Private Sub Command2_Click()

  Static x

  x = Not x

  If x Then

    lv.View = lvwReport

    Call SendMessage(lv.hwnd, _
                      LVM_SETCOLUMNWIDTH, _
                      0&, LVSCW_AUTOSIZE)

  Else

    lv.View = lvwList

  End If

End Sub

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/


| I need to get a list mode ListView to not truncate any entries (i.e. set
| column width to the max required data size).  I've exhausted my list of
| resources (MSDN, VBNet, DejaNews...) to no avail.  The following code
works
| if the LV is in Report mode but not in List mode (contrary to the twice
| amended SetColumnWidth doc), although the equivalent works as expected in
| VC++
|
| Who can help?
|
| Cheers,
| Derek.
|
| Private Sub Command1_Click()
|
|     Dim b As Boolean
|
|     Dim i As Integer
|     For i = 1 To 20
|         lv5.ListItems.Add , , "Really long item, so long it truncates"
|         lv6.ListItems.Add , , "Really long item, so long it truncates"
|     Next i
|
|
|     b = ListView_SetColumnWidth(lv5.hWnd, 0, 400) 'LVSCW_AUTOSIZE)
|     b = ListView_SetColumnWidth(lv6.hWnd, 0, 400) 'LVSCW_AUTOSIZE)
| End Sub
|
|



Fri, 05 Apr 2002 03:00:00 GMT  
 ListView(List Mode) SetColumnWidth does not work
That solution works wonderfully, thank you so much.

I was way too fixated on why the API was not working and forgot completely
to just get done what I wanted to get done.

Cheers,
Derek.

P.S. Still wondering why VC++ works and VB doesn't with respect to this
issue.



Fri, 05 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MouseMove event in ListView does not trigger when ListView in Small/Large Icon View mode

2. Ownerdraw works with ListView 5.0 but not with ListView 6.0

3. Ownerdraw works with ListView 5.0 but not with ListView 6.0 (in this sample)

4. Column Width in List mode (Listview control)

5. colume width of listview in List mode

6. ListView in List mode

7. list mode in the listview control

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

9. Herlp: LIKE in SQL doe not work anymore

10. CreateItemFromTemplate does not work in IMO mode with security

11. PEGetJobStatus Not Working In 32 Bit Mode?

12. ItemCheck event on Listviews not working as expected

 

 
Powered by phpBB® Forum Software