Cellvalidating datagridview c sharp

I have a Data Grid View with a Date (Date Time) Column. When a user edit the cell and change the date I woulk like to allow him to write "081501" and programmatically transform the entered date to "2008/15/01"( using a custom method *called Transform Date(string ARaw Date)) But I can't find any Data Grid View event to call the Transform Date method and replace the user input by the computed value. Does anybody if this kind of transformation *is possible in a Data Grid View and Where is the best place to put the call to the transformation method ? In the following example, the data is stored as 75000 but the user wants the data displayed as "75k" instead.

I have a Data Grid View with a Date (Date Time) Column. Check out the Format and Parse events on the cells.

Cell Validating: it occurs after the cell has finished validating.

Thanks, Rajni Shekhar I fill the information in the Datagridview from Folder, Folder contains File Name, File Size, File Path. S Validating is used when you want to validate any value like value must be integer.

I have a bound Data Grid View with one of its columns bound to a float column of a datatable.

When the contents of a cell in this column are deleted (the user deletes the contents by entering the cell and pressing the delete key on the keyboard) and the user naviagtes away from this cell I get a Format Exception.

Create a data source for the Mortgage database in the folder shown above, if you haven't already done so.

How do I catch this error and enter DBNull.value into the cell.

I can catch the dataerror event and call e.cancel to return to the original value but I want to set the cell value to null (or even 0.0) when the contents have been deleted.

This is the most straight forward method as it envolves no software changes.

Phil I ended up focusing in the data Grid View Cell that i wanted to be in after the carriage return. Phil - thanks for the suggestion but in this case, in this app the carriage return is needed in all other instances.

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.

You must have an account to comment. Please register or login here!