My observation is that DataGridViewComboBoxes *never* work for numeric
Yes, of course it works when the values are in another table, but not when
they are stored in the combo box itself.
The field I used from the Employees table *is* a numeric field. And the
values in it are stored in the Items Collection of the combo box itself.
There is no other place to store them.
The problem you are having therefore has nothing to do with numeric fields.
It has to do with how you're putting values into the
DataGridViewComboBoxColumn, or what those values are. For example, if the
column is bound to a table data source, the values must be in the table it
is bound to or they will not be valid.
There are 4 distinct properties of a DataGridViewComboBoxColumn that come
into play when binding it to a table:
DataSource: The table (object) that the Items Collection is populated from.
If this property is set, you can not use the Items Collection to populate
the DataGridViewComboBoxColumn.
ValueMember: The column in the table that holds the underlying value for
each Item (row).
DisplayMember: The column in the table that holds the displayed value for
each Item (row).
DataPropertyName: The column in the table (BindingSource) that the
DataGridView is bound to. When the value in the DataGridViewComboBoxCell
changes, the value in the BindingSource is changed.
The Items property can be used when the DataSource is not set.
It is important to remember that a DataGridViewComboBoxColumn can be bound
to 0, 1, or 2 different tables. In your case, it sounds like you only want
to bind to a single table. Therefore, the DataSource property should not be
set.
Finally, make sure that your Data Type (the type that you are assigning to
the Items in the Items Collection) is correct if you populate the Items
Collection by hand. The underlying value must be of the same Data Type as
the Data Type of the table column that the DataPropertyName is referring to.
The value displayed will almost always be a string (although it may be an
image). In any case, it must be something human-readable.
For more information, see:
http://msdn2.microsoft.com/en-US/library/system.windows.forms.datagridviewcomboboxcolumn.aspx
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
The man who questions opinions is wise.
The man who quarrels with facts is a fool.