Changing ComboBox Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Schamness

    #1

    Changing ComboBox Data

    I am working on an application as I try to learn/work with Visual
    basic.
    I am writing the application in Visual Studio 2005 and am connecting
    the Application to an Access Database.
    I used the Visual Studio wizard to create the data connection,
    datasets etc.

    I currently have a compbo box that is bound to "Product Description"
    from the tblProducts in my database.
    All appropriate textboxes on my main form are populated correctly
    whenever the combo box loads or the option in the combo box is
    changed.

    Now I have 2 menu items, stemming from a "Select" option.
    I have Select by Product ID and Select by Product Description.

    I would like to choose either product ID , or Product Description and
    have this choice change the information bound to my combo box. So
    instead of displaying product description, it would now display
    Product Id, and vice versa (depending on the Select choice).

    I did not manually code the origional databind for the combo box,
    however should I have to so that I can create these options I will.
    Any advice is greatly appreciated.
    Thank you.

  • RobinS

    #2
    Re: Changing ComboBox Data

    Take out the binding in design mode, and redo it in manual mode.

    This one will show description, but selectedvalue will be ID. If you want
    to show ID, change the DisplayMember to ProductID.

    myComboBox.Data Source = myDataSet.ListB yProductID
    myComboBox.Disp layMember = "ProductDescrip tion"
    myComboBox.Valu eMember = "ProductID"

    or

    This one will show and select description.

    myComboBox.Data Source = myDataSet.ListB yProductDescrip tion
    myComboBox.Disp layMember = "ProductDescrip tion"
    myComboBox.Valu eMember = "ProductDescrip tion"

    See if that helps.

    Robin S.
    ---------------------------------
    "Schamness" <schamness@gmai l.comwrote in message
    news:1174845367 .487960.153380@ l75g2000hse.goo glegroups.com.. .
    >I am working on an application as I try to learn/work with Visual
    basic.
    I am writing the application in Visual Studio 2005 and am connecting
    the Application to an Access Database.
    I used the Visual Studio wizard to create the data connection,
    datasets etc.
    >
    I currently have a compbo box that is bound to "Product Description"
    from the tblProducts in my database.
    All appropriate textboxes on my main form are populated correctly
    whenever the combo box loads or the option in the combo box is
    changed.
    >
    Now I have 2 menu items, stemming from a "Select" option.
    I have Select by Product ID and Select by Product Description.
    >
    I would like to choose either product ID , or Product Description and
    have this choice change the information bound to my combo box. So
    instead of displaying product description, it would now display
    Product Id, and vice versa (depending on the Select choice).
    >
    I did not manually code the origional databind for the combo box,
    however should I have to so that I can create these options I will.
    Any advice is greatly appreciated.
    Thank you.
    >

    Comment

    Working...