DataGridView error

  • Thread starter Thread starter devx
  • Start date Start date
D

devx

Hi, i have DataGridView whose sourse i set to a datatable with 5
columns
containing data. i then remove the 3rd column, created a
DataGridViewComboBoxColumn, set it's DataSource, ValueMember and
DisplayMember. the Valumeber is an integer and the displaymember is a
string. I then instert this into the same location as the column that
was
removed. the problem i am getting is when the Grid is loaded, i get
errors
stating "System.FormatException: the value of the
DataGridViewComboBoxCell is
invalid. To replace this default dialog, please handle the DataError
event.".
Why is this error happening?


here is the code that does the replacing and adding of a combo box:


private void addExchangeLookUpCombs( DataGridView dt )
{
dt.Columns.Remove( "exchange_id" );
DataGridViewComboBoxColumn cb = new
DataGridViewComboBoxColumn( );
cb.DataSource =
DbConnection.instance.getDbTable("StockExchange");
cb.ValueMember = "exchange_id";
cb.DisplayMember = "symbol";


cb.FlatStyle = FlatStyle.Flat;
dt.Columns.Insert( 2, cb );


}
 
Hi,
Were you able to figure this out? I'm getting a similar exception and would
like to know how to resolve it. Thanks.
 
Back
Top