Results 1 to 6 of 6

Thread: Setup listbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Norway
    Posts
    11

    Post

    Hello, is there a way to organize my listbox so that i can have the entries in line:

    Jostein-----Solstad----VB-----Programmer
    John--------Smith------Java---Programmer

    instead of
    Jostein Solstad VB Programmer
    John Smith Java Programmer

    best
    jostein

    [This message has been edited by dialafc (edited 02-01-2000).]

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Change the Listbox's FontName Property to a Fixed Width Font, like Courier.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Norway
    Posts
    11

    Post

    No, thats not what i ment. How can i specify lenght of each entry in the same line in the listbox ?

    is there such a way. in VBA i know u can do it, but can you in normal VB ?


  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use a MSFlexGrid Control instead, ie.
    Code:
    Private Sub Form_Load()
        Dim iIndex As Integer
        
        With MSFlexGrid1
            .FixedCols = 0
            .FixedRows = 0
            .SelectionMode = flexSelectionByRow
            .FocusRect = flexFocusNone
            .Cols = 3
            .Rows = 0
            .ScrollTrack = True
            .ScrollBars = flexScrollBarVertical
            .GridLines = flexGridNone
            .ColWidth(0) = 2000
            .ColWidth(1) = (.Width - 2000) / 2
            .ColWidth(2) = (.Width - 2000) / 2
        End With
        For iIndex = 1 To 10
            MSFlexGrid1.AddItem "Row" & iIndex & " - Column1" & Chr(9) & "Column2" & Chr(9) & "Column3"
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure. You can setup TABSTOPS for the Listbox, so everything in that list would be lined up:

    Code:
    Option Explicit
    Private Const LB_SETTABSTOPS As Long = &H192
    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 Sub Command1_Click()
        With List1
            .AddItem "Jostein" & vbTab & "Solstad" & vbTab & "VB" & vbTab & "Programmer"
            .AddItem "John" & vbTab & "Smith" & vbTab & "Java" & vbTab & "Programmer"
        End With
    End Sub
    
    Private Sub Form_Load()
        Dim arrTabs(2)
            
        arrTabs(0) = 0
        arrTabs(1) = -142
        arrTabs(2) = 154
        
        'clear any existing tabs
        Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0, ByVal 0)
        'set list tabstops
        Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 4, arrTabs(0))
    End Sub
    But for this purpose, you better use Grid or ListView, because you can create headers like: FirstName, LastName, Skills etc, and then populate those columns accordingly.

    Regards,

    ------------------

    Serge

    Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819


  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Norway
    Posts
    11

    Post

    Yes, thnx. This seems to work ok.
    Tough i wonder. How can i set the vbTab sice ? i can set vbTab twice for sure...

    but when some of the fields are short or long, this affects the look of it..not nice

    i seem to have trouble finding this listView thing, wich is something i would like to try to use..



    [This message has been edited by dialafc (edited 02-01-2000).]

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