Results 1 to 7 of 7

Thread: ListView Control...

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    56

    ListView Control...

    Hi,

    I'm trying to use the listview control to display a list of items, as a list, but after 18 characters or so, it keeps going like this:

    12345678910abc...
    12345678910abc...
    12345678910abc...

    And wont display the full string, but just three trailing dots to indicate that there's more. Is there anyway of displaying the entire text in a row? Rather than all the rows being a fixed width?

    I need to use a listview, rather than a listbox, as I intend in formatting the colour of texts etc which I understand isn't possible in a standard listbox.

    Thanks

    Snowblind

  2. #2
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: ListView Control...

    Use the Report view and then set the width of the ColumnHeaders.
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    56

    Re: ListView Control...

    Having just looked at something, if you click the command button twice, it does display the results sort of how I'd like them to, but you get two sets of results then!

  4. #4
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: ListView Control...

    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  5. #5

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    56

    Re: ListView Control...

    VB Code:
    1. Private Sub Form_Load()
    2.     ListView1.ListItems.Add , , "ThisIsALongStringOfTextThatDoesntFit"
    3.     ListView1.ListItems.Add , , "ThisIsANOTHERLongStringOfTextThatDoesntFit"
    4.    ListView1.ListItems.Add , , "ThisIsYETANOTHERLongStringOfTextThatDoesntFit"
    5.    
    6. End Sub


    Obviously windows common controls have been added to allow for the Listview, and the view is set to lvwlist... I did try the previous advice, setting it to report, but couldn't figure out how to set the column headers. If I can't get this to work, I might have to use a rich text box, but that'd be a bit lame, as I'd rather have it in a list box, for ease of finding, and for row select etc.

    Thanks for all your help,

    Ammendment:
    As an afterthought.... I did try ListView1.ListWrap = False or something like that, but to no avail...

  7. #7
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: ListView Control...

    Create a new ListView, Label and CommandButton. Set ListView view property to report and create a ColumnHeader and don't change anything. Than try this code:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.    With Label1
    5.       .Visible = False
    6.      
    7.       'put in here the longest line with Len(yourStrings)
    8.       .Caption = "ThisIsYETANOTHERLongStringOfTextThatDoesntFit" 'f.e.
    9.       .AutoSize = True
    10.    End With
    11.    
    12.    With ListView1
    13.       .ListItems.Add , , Label1.Caption
    14.       .ColumnHeaders(1).Width = Label1.Width + 200
    15.    End With
    16. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width