Results 1 to 9 of 9

Thread: Multiple Fields in a Combo Box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148

    Lightbulb

    Howdy!

    I want to put more than one field from a DB in a combo box. I am using the standard combo box control. How do you do it

    This example puts the 'pipe sign between, but I want to see seperate fields.

    example:

    cmb1.clear

    Do While Not Adodc1.Recordset.EOF
    vntTemp = Trim(Adodc1.Recordset.Fields(0))
    vntTemp2 = Trim(Adodc1.Recordset.Fields(1))

    cmb1.AddItem (vntTemp & "|" & vntTemp2)
    vntTemp = ""
    vntTemp2 = ""

    Adodc1.Recordset.MoveNext
    Loop


    Thanx

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    The pipe, or any other character or spaces, is the only thing you can do for the combo. It is no made for that.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    What is made for it?

    What I need is a combobox that displays only one of the fields example 'Index' and when you click on the drop down, you will see the index field plus an additional field - Name

    1 - bob
    2 - mary
    etc.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    The whats wrong with the example you have? Just replace the "|" with a "-"
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    it has a ugly format and I have to Accommodate for spacing

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Well unfortunatly thats about the best you can do..But that gives me an idea. when im finished writting the component i am writting now, maybe Ill try to tackle making a drop down listview..hmmm. Would be interesting!
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    You could always use a fixed width font and get the effect of having columns.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  8. #8
    Member
    Join Date
    Feb 2001
    Location
    Hyd - INDIA
    Posts
    57

    Thumbs up Her try this out !

    For intCounter = 1 To intRecCount
    Combo1.AddItem "" & rs!CUSTOMER & " " & " " & ""
    & " " & rs!CUST_CD
    rs.MoveNext
    Next intCounter


    The more spacing u want between the two fields add another " " .

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    looks good!

    thanx
    Hyme

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