have a problem whith comboboxcell in datagridview
It works fine, i can choose any value, but when combobox is focused and
i hit ESC key a messagebox with an exception error is shown saying :
The following exception ocurred in the DataGridView:
System.FormatException: DataGridViewComboBoxCell value is not valid
To replace this dialog please handle the DataError event.
HOW TO HANDLE this kind of DataError events ?
please HELP..
my code:
double Precio=1;
double Precio2=2;
double Precio3=3;
double Precio4=4;
int CurrentRow=0;
int iPrecio=1;
//note: each cell of column Precio has different combobox
ArrayList aPrecios = new ArrayList();
aPrecios.Add(new PrecioVal(Precio));
aPrecios.Add(new PrecioVal(Precio2));
aPrecios.Add(new PrecioVal(Precio3));
aPrecios.Add(new PrecioVal(Precio4));
DataGridViewComboBoxCell x_CmbPrecios = new
DataGridViewComboBoxCell();
x_CmbPrecios.DataSource = aPrecios;
x_CmbPrecios.ValueMember = "Precio";
x_CmbPrecios.DisplayMember = "PrecioVisible";
gvDetalles.Rows[CurrentRow].Cells[iPrecio] = x_CmbPrecios;
gvDetalles[gvFac.iPrecio, CurrentRow].Value = Precio;
//-----------
// PRECIOVAL CLASS
public class PrecioVal
{
private double _Precio;
public double Precio
{
get { return _Precio; }
set { _Precio = value; }
}
public string PrecioVisible
{
get { return _Precio.ToString("0.00"); }
}
public PrecioVal(Double vP){
_Precio=vP;
}
}