Results 1 to 4 of 4

Thread: Combo Box

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    13

    Combo Box

    I have a combo box on screen

    I have this code which is not working

    tcmbType.dataset = ds.tablename(0)
    tcmbType.displayMember = "Card Type"

    It is giving me an error. Can someone post me an example of how to populate combo box with values and than select the value via code according to the data you have on the screen.

    cheers
    manuel

  2. #2
    Lively Member Ksyrium's Avatar
    Join Date
    Jun 2004
    Location
    Tennessee..yes, we CAN code!!
    Posts
    80
    If you are populating a combo box at runtime with consecutive values (i.e., 1, 2, 3...) then..
    VB Code:
    1. For x = 1 To 10
    2.       ComboBox1.Items.Add(x)
    3. Next

    As far as binding controls to a dataset, look into DataBindings.
    You may follow, but not to close!

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,963

    Re: Combo Box

    Originally posted by mcaruana
    I have a combo box on screen

    I have this code which is not working

    tcmbType.dataset = ds.tablename(0)
    tcmbType.displayMember = "Card Type"

    It is giving me an error. Can someone post me an example of how to populate combo box with values and than select the value via code according to the data you have on the screen.

    cheers
    manuel
    Try

    tcmbType.DataSource = ds.tablename

    Can't think why you used a parameter or element number, unless you have an array of DataSets
    Last edited by taxes; Sep 22nd, 2004 at 10:30 AM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    Hyperactive Member fret's Avatar
    Join Date
    Sep 2004
    Posts
    472
    I have a combo box on screen

    I have this code which is not working

    tcmbType.dataset = ds.tablename(0)
    tcmbType.displayMember = "Card Type"

    It is giving me an error. Can someone post me an example of how to populate combo box with values and than select the value via code according to the data you have on the screen.
    tcmbType.DataSource = ds.Tables(0)
    tcmbType.DisplayMember = "Card Type"
    be sure to match the displayMember = "Card Type" to the particular field of the table you are reffering or else it is an error an no display will appear in your combobox.
    and in order to select value in your combobox try to add tcmbType.ValueMember = "name"
    like this:
    VB Code:
    1. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    2.         TextBox1.Text = ComboBox1.SelectedValue.ToString
    3.     End Sub
    hope i'm not misleading
    Last edited by fret; Sep 22nd, 2004 at 08:14 PM.

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