I handle the validation in the Cell Validating event, and if the cell is invalid display an error message, then cancel the exit of edit mode.However I would also like to erase the content of the cell currently in edit mode.Be careful that if a user does a copy and paste into a control it bypasses the validation check.Displaying a Combo Box in Cell Frequently, besides displaying text in a cell you may want to display a drop-down list box to allow users to select from a list of pre-determined values. In order to achieve this, you need to perform two things: - the Drop Down Stype property of the Combo Box editing control needs to be set to Drop Down. - ensure that the value that the user typed into the cell is added to the combo box items collection.A combo box cells value has to be in the items collection, otherwise a Data Error event will be fired, so that's the reason why you need to perform this step.It seems to do this ok but when I load the formatted value into the cell, the cell doesn't reflect the formatted value rather just what I typed in. If you really do want to format the data to show four decimal places then you simply set the Default Cell Style. It doesn't actually look like formatting is what you're doing anyway.
Add("Type C") '---create a combobox column--- Dim combo Box Col As New Data Grid View Combo Box Column '---set the header--- combo Box Col. 0 in it, which means that all the data I need to have at the end in the column consisnt only of positive integers.The problem here is, that I want to check if the user has entered a double and if he has, to convert it to int. I hope you wouldn't consider my post lame, I just want to be informated about the best I could do. An alternative way would be to add the items to the Data Grid View Combo Box Column control directly, as shown: '---adding columns--- Data Grid View1.
Data Source = bindingsource '---add a combobox column to the Data Grid View control--- Data Grid View1. Add(combo Box Col) The previous code showed how you can bind a Binding Source control (containing a list of items to let the users choose) to a Data Grid View Combo Box Column control inside a Data Grid View control. Header Text = "Types" '---add items to it--- combo Box Col.