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

Thread: Combo Box

  1. #1
    Join Date
    Oct 2000
    Posts
    34

    Combo Box

    I have the combo box on the form. The Style property is Dropdown List. It is populated by the code bellow:

    Do Until rsNext.EOF
    frmLogin.cboTeam.AddItem rsNext![full_name]
    frmLogin.cboTeam.ItemData(frmLogin.cboTeam.NewIndex) = rsNext![AssociateID]
    rsNext.MoveNext
    Loop

    I need to select some item, let say 'John Smith', pragmatically. Can I do that?
    Thanks



  2. #2
    Join Date
    Jan 2002
    Location
    Quebec/Canada
    Posts
    124

    Re: Combo Box


    Do Until rsNext.EOF
    frmLogin.cboTeam.AddItem rsNext![full_name]
    frmLogin.cboTeam.ItemData(frmLogin.cboTeam.NewIndex) = rsNext![AssociateID]
    If (rsNext![Full_Name] = "John Smith") then
    frmLogin.cboTeam.ListIndex = frmLogin.cboTeam.NewIndex
    End If
    rsNext.MoveNext
    Loop



    Is that what you want ?
    Heulsay


  3. #3
    Join Date
    Mar 2001
    Posts
    71

    Re: Combo Box

    You can select a particular value by using following code:

    Combo1.listindex = 1
    where 1 is the index of item in the list
    This will select the second item in the combo box.

    Remember Items in Combo start from 0 i.e. Index of first item in combo is 0


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