0

As clear from the title, my datagridviewComboboxCell, which I am adding to selected cells only, are showing it's dropdown list perfectly, and I can select them seamlessly. Problem arises when the combobox losses focus, it forgets everything about selected item and auto selects the item at index 0, of it's range collection. And many time, a 'DataGridViewDataErrorEvent' is occuring(I traced it by adding DataError event handler). I can not understand what is going wrong to cause the error to fire. Moreover even though I daclare e.Cancel = false; in the eventhandler, the ComboBox auto-selects item at index 0. Plese help me out of this. N.B . I forgot to add initially(when it appears to screen!), the DataGridViewComboBox has no item selected. EDIT:- Code snippet

//Creating and Adding propertiesof     DataGridViewComboBoxCell.

RegViewdataGridView.Rows[uniqcustCount].Cells[day].ReadOnly = false;    //uniqcustCount & day Are Integers
var pcmbcell = new DataGridViewComboBoxCell();
var tcmbcell = new DataGridViewComboBoxCell();
RegViewdataGridView[day,uniqcustCount] = pcmbcell;
pcmbcell.ReadOnly = false;
pcmbcell.DropDownWidth = 80;
pcmbcell.DataSource = shipdPrdLst;
pcmbcell.DisplayStyle =      DataGridViewComboBoxDisplayStyle.ComboBox;
RegViewdataGridView.DataError += RegViewdataGridView_DataError;

 void RegViewdataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
    e.Cancel = false;
}
  • Yes, I have written some code to generate the DataGridViewComboBoxCell & add item to it. But I'm first time working with such nasty combobox that does not have a Selected index change, event. :( anyway I think I'm surely doing something wrong, but failing to trace out where! Should I add my code? – Rajib Majumdar Sep 23 '16 at 17:57
  • Yup! just 5 minute! – Rajib Majumdar Sep 23 '16 at 17:59
  • There's no code here. There's nothing anybody could use to figure out what your problem is. Please include enough code for somebody to reproduce the issue you're having. – 15ee8f99-57ff-4f92-890c-b56153 Sep 23 '16 at 18:06
  • Oh God! finaly out of the problem! pcmbcell.ValueType = typeof(int); absence of this tiny code was killing me. :( – Rajib Majumdar Sep 24 '16 at 03:25

0 Answers0