Results 1 to 4 of 4

Thread: [RESOLVED] [2.0] binding combobox inside in the datagrid

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] [2.0] binding combobox inside in the datagrid

    Hi ,

    I have a datatable object and a comboxbox type field inside my datagridview name contactnameCombo created from a design time. I want to bind that combobox to a datatable field object during run time.




    thanks,
    popskie

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] binding combobox inside in the datagrid

    Just like a regular ComboBox, a DataGridViewComboBoxColumn has DataSource, DisplayMember and ValueMember properties. Reading the documentation would have told you that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: [2.0] binding combobox inside in the datagrid

    Hi JM,
    I came out this code but no data will came out to the combox. I include the screen capture of the output.

    DataSet dt = new DataSet();
    dadapter.Fill(dt, "Customers");
    cb1.DataSource = dt;
    cb1.ValueMember = "customerid";
    cb1.DisplayMember = "ContactName";

    Thanks,
    Popskie

  4. #4

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: [2.0] binding combobox inside in the datagrid

    Quote Originally Posted by popskie
    Hi JM,
    I came out this code but no data will came out to the combox. I include the screen capture of the output.

    DataSet dt = new DataSet();
    dadapter.Fill(dt, "Customers");
    cb1.DataSource = dt;
    cb1.ValueMember = "customerid";
    cb1.DisplayMember = "ContactName";

    Thanks,
    Popskie

    Nevermind this, I miss this line. cb1.DataSource = dt.Tables["customers"];

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