Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridView Escape Key + ComboBox cell problem
 

DataGridView Escape Key + ComboBox cell problem



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;
}

}


Alexei Vi  Monday, February 06, 2006 3:54 PM
try this link

http://msdn2.microsoft.com/en-us/library/t4a23xx4.aspx
nyashaC  Friday, June 29, 2007 6:57 AM
try this link

http://msdn2.microsoft.com/en-us/library/t4a23xx4.aspx
nyashaC  Friday, June 29, 2007 6:57 AM

You can use google to search for other answers

Custom Search

More Threads

• DBNull error
• Problem with AxOWC11.AxSpreadsheet control
• Doesn't beep when bound controls fail validation (bound to business object)
• Databound listbox not updating
• How do i display a messagebox without Titlebar But should have OK & Cancel buttons?
• DataGridViewCheckboxColumn DbNull issue
• Why he Dont Dispaly any Data ??
• DataGridView DateTime format for "12:01:00 P"
• Datagrid "Focused Grey Box" problem?
• Crystal Reports TextObject