CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Location
    Stuttgart, Germany
    Posts
    80

    Problems with ListBox!!!

    Hello,

    my entries in List1 (ListBox) are to long, so they cannot be displayed right. how can I create a horizontal scrollbar or let appear the unvisible part one line down?

    Thanks a lot for your help!!!

    AScomp


  2. #2
    Join Date
    Dec 1999
    Location
    Tel Aviv, Israel, Earth, Solar System
    Posts
    50

    Re: Problems with ListBox!!!

    You can use a picturebox with hidden method .Print - something like Picture1.Print List1.List(Index).
    If it looks too complicated - let me know and I'll send you an example - I have it at home already done (met the same problem some day)

    Jean Spector
    Tech Support Team Leader, CET
    [email protected]
    (in VB from 11/1999)

  3. #3
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Problems with ListBox!!!

    You can use the following code to find out the max-length of your widest item in the listbox and then set a Horizontal scrollbar in the listbox :

    Create a new project with a form (FORM1) a listbox (LIST1) and a button (Command1) and paste in the following code :


    option Explicit
    '
    private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, _
    lParam as Any) as Long
    '
    private Const LB_SETHORIZONTALEXTENT = &H194
    '
    private Sub Command1_Click()
    Dim lMaxLen as Long
    Dim lCount as Long
    '
    for lCount = 0 to List1.ListCount - 1
    If TextWidth(List1.List(lCount)) > lMaxLen then
    lMaxLen = TextWidth(List1.List(lCount))
    End If
    next
    '
    lMaxLen = lMaxLen / Screen.TwipsPerPixelX ' if twips change to pixels
    SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, lMaxLen, 0&
    '
    End Sub





    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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

Featured