简体   繁体   中英

combobox items not show in datagridview

I have a win form project in c#, there is a combo box in a datagridview. it has 2 items which added in design. when I run the program, the combo box is empty. why? please help me I added the items in Design mode and it doesn't show anything then I added items programatically and it doesn't work either.

Here is the code:

  cbcCell = (DataGridViewComboBoxCell)dgvFolder.Rows[0].Cells[1];
  cbcCell.Items.Add("cat");
  cbcCell.Items.Add("dog");

Without too much information here, the likely problem here is that the ComboBox has the ReadOnly property set to true . You can fix this by going into Design View , click the little arrow that appears in the top left of the DataGridView , select Edit Column , select the appropiate column/cell, and change the ReadOnly property to false .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM