Cellvalidating cancel


I know how we can do this, however, I just need to know how you bind your datagrid... If you let me know, I'll write you a handler so that we can examine the value in your validating event, and if the date is not proper, we can examine the underlying datasource, and view the .

Original Value of the column for the row, and if it was null, then we can simply reset that value to null.

The user is allowed to edit various fields on the datagridview, and I am trying to validiate the date fields before trying to update the database. OK, I got it working, but I'm not pleased with my solution.

Load ' Initialize the Binding Source and bind the Data Grid View to it. Data Source = Get Data("select * from Customers") Grid View1. Auto Resize Columns( _ Data Grid View Auto Size Columns Mode.

Cancel = True End If End Sub Private Sub data Grid View1_Cell End Edit(By Val sender As Object, _ By Val e As System. Cell End Edit ' Clear the row error in case the user presses ESC. For more information, see Protecting Connection Information.

Empty End Sub Private Shared Function Get Data(By Val select Command As String) As Data Table Dim connection String As String = _ "Integrated Security=SSPI; Persist Security Info=False;" _ "Initial Catalog=Northwind; Data Source=localhost; Packet Size=4096" ' Connect to the database and fill a data table. Also see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.


You can also build this example in Visual Studio by pasting the code into a new project.

Incidently, thanks for the points, although I'd like to work with you a bit further on this...



  1. Pingback:

  2. eric   •  

    The Japanese calendar is used, in particular, on Japanese coins and bank notes.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>