CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Combo Box

  1. #1
    Join Date
    Jan 2000
    Location
    Pune, Maharashtra, India
    Posts
    7

    Combo Box

    i want the combo box that i am using to display multile columns.
    how do i do it.
    i am using it for database progg.
    reply asap.
    Regards,


    Tejas Jois

  2. #2
    Guest

    Re: Combo Box

    combo boxes don't have a multi-column option, and how would you use it if they did? List boxes do. If that's what you were referring to then for a list box set lb.columns = n where n > 0 and as many columns as needed will be made to hold the data.




  3. #3
    Join Date
    Jan 2000
    Location
    Pune, Maharashtra, India
    Posts
    7

    Re: Combo Box

    i want the list box controls to refer to differnet columns.
    i.e. the first column shld rfer to one field in the database,while the next column shld refer toanother field. how do i do this.??



    Tejas Jois

  4. #4
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Combo Box

    Without going to a third party control - this is the best you can do:


    Use the Win32 API to set tab stops in a Visual Basic list box by creating these declarations and routine in a module:

    public Const LB_SETTABSTOPS = &H192
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (byval hwnd as Long, _
    byval wMsg as Long, _
    byval wParam as Long, _
    lParam as Any)as Long

    Sub SetListTabStops(iListHandle as Long)
    ' sets 2 tab stops in a list box at the 24th
    ' and 48th character
    ' iListHandle = the window handle of the list box
    Dim iNumColumns as Long
    Dim iListTabs(1) as Long
    Dim Ret as Long

    iNumColumns = 2

    iListTabs(0) = 96 ' 96/4 = 24 characters
    iListTabs(1) = 192 ' 192/4 = 48 characters

    Ret = SendMessage(iListHandle, LB_SETTABSTOPS, iNumColumns, iListTabs(0))
    End Sub




    In your form, create a list box called lstMyListBox. Call this routine in the form load to set your tab stops:

    Call SetListTabStops(lstMyListBox.hwnd)



    Then add items to the list box using vbTab:

    lstMyListBox.AddItem "Column 1 data" & vbTab & "Column 2 data"




    You can adjust the number of columns and their width by change the values of iListTabs().

    Hope this helps,
    John


    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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