datagridviewcombobox not populating.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • taranpreet
    New Member
    • Jul 2010
    • 1

    #1

    datagridviewcombobox not populating.

    there is a data grid view with columns item ,quantityleft,q uantity,unit,pr ice per unit,discount

    from these "item" is combobox which must be defined from a table "stock" having columns iname,iid,etc
    iname should come in the combobox.
    how should i do it have tried both combobox column and combobox cell.

    private void sell_Load(objec t sender, EventArgs e)
    {

    //dataGridView1.S electedColumns.
    SqlDataAdapter adapter1 = new SqlDataAdapter( "select * from [stock] where uid =" + id+"and compid="+cid, con);
    DataSet ds2 = new DataSet();
    SqlCommandBuild er cmd1 = new SqlCommandBuild er(adapter1);
    adapter.Fill(ds 2, "[stock]");
    //DataGridViewCom boBoxColumn i = new DataGridViewCom boBoxColumn();

    /////DataGridViewCom boBoxColumn dd = dataGridView1.C olumns[0];
    //i.DataSource = ds2;
    //DataGridViewCom boBoxCell dd = (DataGridViewCo mboBoxCell)data GridView1.Rows[0].Cells[0];
    DataGridViewCom boBoxColumn dd = (DataGridViewCo mboBoxColumn)da taGridView1.Col umns["item"];
    dd.DataSource = ds2;
    //dd.
    //dd.DisplayMembe r = "iname";
    //dd.ValueMember= "iname";
    }
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #2
    ComboBox cell's only populate when the data from the data source corrosponds with an item in the cell template. Id suggest making sure your cell knows how to handle the data first.

    good luck :)

    Comment

    Working...