DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Another Combo Box question

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Another Combo Box question

    [Originally posted by alfwong1]

    retrieve data from database
    for example Coutry database with
    ID Country
    1 USA
    2 UK
    3 Australia
    4   Canada

    can i ADD both ID and Country into Combo box
    When user select Canada
    it will return to 4
    thank you for your help

    Also how can i create my own ico image file? What program?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Another Combo Box question

    [Originally posted by veetian]

    i know in FoxPro a combo box can have more than one column, but i do not know how to achieve this in VB.

    the approach i used to this issue is to add both value into a single selection.

    for example you may see this in the selection
    USA (12)
    XXX (20)


    so when the user selects it you can return the value in the bracket.


    veetian

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Another Combo Box question

    [Originally posted by alfwong1]

    Therefore it will shows
    USA(20) on the combo box
    is there anyway to show USA only

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Another Combo Box question

    [Originally posted by John Citizen]

    I use an old version of graphix workshop to create .ico files. However you can do this work around for live icons in the top of corner of your window(not so helpful for your project icon on the desktop however):

    (You will need to add the ImageList control to your project - you can load different types of formats this way)

    Private Sub Form_Load()
    Set Me.Icon = MyImageList.ListImages(1).ExtractIcon
    End Sub

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Another Combo Box question

    [Originally posted by John Citizen]

    If your ID numbers are incremental (eg 1, 2, 3 ... etc) you can use read the index property of the combo box as the ID number. (The index increments with each item added)

    Otherwise the default combo box with VB does not allow you to do this. You can easily create an array/collection to reference the ID and Country.

    Or if you desperately want the control to do it you can try this royaltee free control - http://www.vbaccelerator.com/codelib/odcbolst/article.htm

    John Citizen
    NeocomIT
    www.neocomit.com.au

  6. #6
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Another Combo Box question

    [Originally posted by veetian]

    The array/collection method mentioned by John Citizen can be achieved like this:

    First, you determine the amount of elements in the combo box.

    Private Sub Form_Activate()
    'The amount of elements in the combo box
    Dim amount As Integer
    amount = 10
    Dim Elements(amount) As Integer
    'Elements store the ID in corresponding to your combo box

    Dim i As Integer
    For i = 0 To amount
    Combo1.AddItem recordSet("Country")
    Elements(i) = recordSet("number")
    Next

    'Replace the recordSet("") with your data and you should get what you want.
    End Sub

    Private Sub Combo1_Click()
    'Returns the number corresponding to the item the user chose
    MsgBox Elements(Combo1.ListIndex)
    End Sub



    I guess that should solve your problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center