working with datagridcombobox column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Devaraj1987
    New Member
    • Dec 2011
    • 2

    working with datagridcombobox column

    Hi,
    I have a datagrid in which i have a datagridcombo box(editable),I have populated the combobox manualy by using the following code.

    DataGridViewCom boBoxColumn Actioncolumn = new DataGridViewCom boBoxColumn();
    Actioncolumn.Da taPropertyName = "ZSL_Action ";
    Actioncolumn.He aderText = "Action";
    string[] installs = new string[] { "red", "white", "green" };
    Actioncolumn.It ems.AddRange(in stalls);
    //Actioncolumn.It ems.Add("red");
    //Actioncolumn.It ems.Add("white" );
    //Actioncolumn.It ems.Add("green" );
    Actioncolumn.Re adOnly = false;
    dataGridView1.C olumns.Add(Acti oncolumn);

    Now went i try to change the combo box value , DataError occurs. What shall i do.

    Also by default only 1st value(i.e., Red) is assigned to the combo box. what shall i do.
  • adriancs
    New Member
    • Apr 2011
    • 122

    #2
    Code:
    DataGridViewComboBoxColumn Actioncolumn = new DataGridViewComboBoxColumn();
    Actioncolumn.DataPropertyName = "ZSL_Action";
    Actioncolumn.HeaderText = "Action";
    string[] installs = new string[] { "red", "white", "green" };
    Actioncolumn.Items.AddRange(installs);
    //Actioncolumn.Items.Add("red");
    //Actioncolumn.Items.Add("white");
    //Actioncolumn.Items.Add("green");
    Actioncolumn.ReadOnly = false;
    dataGridView1.Columns.Add(Actioncolumn);
    
    dataGridView1.Rows[dataGridView1.Rows.Add()].Cells[Actioncolumn.Index].Value = "white";
    dataGridView1.Rows[dataGridView1.Rows.Add()].Cells[Actioncolumn.Index].Value = "green";
    dataGridView1.Rows[dataGridView1.Rows.Add()].Cells[Actioncolumn.Index].Value = "red";

    Comment

    • Devaraj1987
      New Member
      • Dec 2011
      • 2

      #3
      still its not Its not working.
      Same dataerror is occuring

      Comment

      • adriancs
        New Member
        • Apr 2011
        • 122

        #4
        I can run the code without error.
        So, what is your error?
        Show your code.

        Comment

        Working...