try abc

try abc

  • NA
  • 199
  • 410.1k

Problem In DATAGRIDVIEWComboBox : datagridviewcomboboxcell value is not valid.

Jan 30 2008 6:37 AM
    Hello, all.. I am using one DatagirdviewcomboBox... and Adding data Programatically..
but it give me this error."datagridviewcomboboxcell value is not valid. "..
My code is here.. plz help..

there are two column in grid and the second column type is Comboboxcell.               

            dgv.Rows.Add(3);
           
            dgv.Rows[0].Cells[0].Value = "Default";
            dgv.Rows[1].Cells[0].Value = "Allow ";
            dgv.Rows[2].Cells[0].Value = "Show ";

            DataGridViewComboBoxCell cmbDefault= new DataGridViewComboBoxCell();
            cmb.Items.AddRange(new object[] { "Weighted" , "Last", "Standard" });
            dgv.Rows[0].Cells[1] = cmb;

            DataGridViewComboBoxCell cmbAllow = new DataGridViewComboBoxCell();
            cmbAllow.AddRange(new object[] { "Yes", "No", "Warning" });
            dgvRows[1].Cells[1] = cmbAllow;

            DataGridViewComboBoxCell cmbShow= new DataGridViewComboBoxCell();
            cmbShow.Items.AddRange(new object[] { "Yes", "No" });
            dgv.Rows[2].Cells[1] = cmbShow;

          // assigning value
            for (int i = 0; i < dtInventory_Setting.Rows.Count; i++)
            {
               dgv.Rows[i].Cells[1].Value ="ABC";
            }