c# - Data grid view text box event handler -
i stuck annoying problem, glad help.
i have datagridview 6 columns (one combo box , others text boxes). want handle textchange(text box) event , selectedindexchange event(combo box), keep error , don't know why. this error: an exception of type 'system.formatexception' occurred in mscorlib.dll not handled in user code additional information: input string not in correct format.
this code
datagridview1.editingcontrolshowing += (sender, e) => { if (datagridview1.currentcell.columnindex == 0) { combobox cb = (combobox)e.control; cb.selectedindexchanged += (sender2, e2) => { this.client.roaming[datagridview1.currentcell.rowindex].country = cb.text; //dictionaries.gettypedict()[country.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.tostring(cb.text)); }; } else { textbox tb = (textbox)e.control; tb.textchanged += (sender1, e1) => { if (datagridview1.currentcell.columnindex == 1) { this.client.roaming[datagridview1.currentcell.rowindex].minutesincomingandoutcomingfromabroadtoisrael = convert.todouble(tb.text); //dictionaries.gettypedict()[minutesincomingandoutcomingfromabroadtoisrael.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.todouble(tb.text)); } if (datagridview1.currentcell.columnindex == 2) { this.client.roaming[datagridview1.currentcell.rowindex].minuteslocalabroad = convert.todouble(tb.text); //dictionaries.gettypedict()[minuteslocalabroad.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.todouble(tb.text)); } if (datagridview1.currentcell.columnindex == 3) { this.client.roaming[datagridview1.currentcell.rowindex].minutesabroadtoabroad = convert.todouble(tb.text); //dictionaries.gettypedict()[minutesabroadtoabroad.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.todouble(tb.text)); } if (datagridview1.currentcell.columnindex == 4) { this.client.roaming[datagridview1.currentcell.rowindex].smsfee = convert.todouble(tb.text); //dictionaries.gettypedict()[smsfee.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.todouble(tb.text)); } if (datagridview1.currentcell.columnindex == 5) { this.client.roaming[datagridview1.currentcell.rowindex].internetfee = convert.todouble(tb.text); //dictionaries.gettypedict()[internetfee.name + datagridview1.currentcell.rowindex.tostring()].invoke(convert.todouble(tb.text)); } }; } };
option 1: string try convert double not in correct format.
option 2: described here: input string not in correct format #2
Comments
Post a Comment