Column Width in List mode (Listview control) 
Author Message
 Column Width in List mode (Listview control)

With the Listview control how can you change the width of the column in the
list view.

I build the list from a db and use the following code

lvwAvailable.Listitems.clear

While Not objRStemp.EOF
    sKeyword = objRStemp.Fields(0).Value
    Set lix = lvwAvailable.ListItems.Add(, sKeyword, sKeyword)
    lix.ToolTipText = sKeyword
    objRStemp.MoveNext
  Wend

I have tried everything but the default size remains.

Can anyone help?

Cheers
Ric Pullen



Sun, 18 Apr 2004 00:20:41 GMT  
 Column Width in List mode (Listview control)
Looking at your code, you only have one column?

IIRC you set the width by setting the columnheader width,
but I seem to recall it doesn't work too well.

Go to http://www.mvps.org/vbnet/ for some handy routines for
sizing listview columns.

J


released on Tue, 30 Oct 2001 16:20:41 -0000 bearing the
following fruit:

Quote:
>With the Listview control how can you change the width of the column in the
>list view.

>I build the list from a db and use the following code

>lvwAvailable.Listitems.clear

>While Not objRStemp.EOF
>    sKeyword = objRStemp.Fields(0).Value
>    Set lix = lvwAvailable.ListItems.Add(, sKeyword, sKeyword)
>    lix.ToolTipText = sKeyword
>    objRStemp.MoveNext
>  Wend

>I have tried everything but the default size remains.

>Can anyone help?

>Cheers
>Ric Pullen



Sun, 18 Apr 2004 00:45:50 GMT  
 Column Width in List mode (Listview control)

Try ListView.ColumnHeaders(X).Width = Y

--
--
Dmitry B. Grekov

Military Insurance Company
Moscow, RUSSIA



Sun, 18 Apr 2004 00:45:03 GMT  
 Column Width in List mode (Listview control)
Cheers but I'm still getting very weird results. I only want to work in the
"List" view of the control therefore only use one column.

Some times the columns are bigger than other times.  Words are "..." even
though they should easily fit in the column.
I tried the Code but that still does not work.

I have a routine that displays a set of alphabetical buttons and once
pressed it displays a set of key words starting with that letter.
I clear the list and repopulate it again.  Using the code below, it kills
this process, nothing is displayed. after another selected button.

As I said weird.

Using the columnheader(x).width does nothing.  I get the same 1440 value
even when the column widths are visbibly quite different.

So can anyone help.

Private Sub lvwAutosizeItems(lvw As ListView)

  'Size each column based on the width
  'of the widest list item in the column.
  'If the items are shorter than the column
  'header text, the header text is truncated.

  'You may need to lengthen column header
  'captions to see this effect.
   Dim col2adjust As Long

   For col2adjust = 0 To lvw.ColumnHeaders.Count - 1

      Call SendMessage(lvw.hwnd, _
                       LVM_SETCOLUMNWIDTH, _
                       col2adjust, _
                       ByVal LVSCW_AUTOSIZE)
   Next

End Sub


Quote:
> With the Listview control how can you change the width of the column in
the
> list view.

> I build the list from a db and use the following code

> lvwAvailable.Listitems.clear

> While Not objRStemp.EOF
>     sKeyword = objRStemp.Fields(0).Value
>     Set lix = lvwAvailable.ListItems.Add(, sKeyword, sKeyword)
>     lix.ToolTipText = sKeyword
>     objRStemp.MoveNext
>   Wend

> I have tried everything but the default size remains.

> Can anyone help?

> Cheers
> Ric Pullen



Sun, 18 Apr 2004 17:22:37 GMT  
 Column Width in List mode (Listview control)
Further investigation seems to indicate that the size of the column is based
on the first item in the list

Any ideas?


Quote:
> With the Listview control how can you change the width of the column in
the
> list view.

> I build the list from a db and use the following code

> lvwAvailable.Listitems.clear

> While Not objRStemp.EOF
>     sKeyword = objRStemp.Fields(0).Value
>     Set lix = lvwAvailable.ListItems.Add(, sKeyword, sKeyword)
>     lix.ToolTipText = sKeyword
>     objRStemp.MoveNext
>   Wend

> I have tried everything but the default size remains.

> Can anyone help?

> Cheers
> Ric Pullen



Sun, 18 Apr 2004 18:55:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to change column width in ListView control in lvwList mode

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

3. ListView column width = ListView width ?

4. colume width of listview in List mode

5. Total width of columns = Width of ListView

6. Total width of columns = Width of ListView

7. Total width of columns = Width of ListView

8. Total width of columns = Width of ListView

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

10. Setting column widths in Listview control

11. ListView control column headers position and width

12. Column widths in ListView control

 

 
Powered by phpBB® Forum Software