thanxxxxxxxxxxx If you have attached an event handler to the Cell Validating event then it will always fire when focus leaves the cell.
There are two ways to manage unwanted execution of event handlers. Data Grid View Cell Validating Event Args' does not contain a constructor that takes '1' arguments" what is the solution for this???????When you display data entry functionality to users, you frequently have to validate the data entered into your form.The Data Grid View class provides a convenient way to perform validation before data is committed to the data store. Text = "Data Grid View validation demo (disallows empty Company Name)" End Sub Private Sub Form1_Load(By Val sender As System. All Cells Except Header) End Sub Private Sub data Grid View1_Cell Validating(By Val sender As Object, _ By Val e As Data Grid View Cell Validating Event Args) _ Handles data Grid View1. Header Text ' Abort validation if cell is not in the Company Name column. Equals("Company Name") Then Return ' Confirm that the cell is not empty. 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. If the event handler for the Cell Validating event finds that the value is an empty string, the Data Grid View prevents the user from exiting the cell until a non-empty string is entered. For a complete explanation of this code example, see Walkthrough: Validating Data in the Windows Forms Data Grid View Control. 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. Data Grid View Cell Event Args) _ Handles data Grid View1. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. Dim adapter As New Sql Data Adapter(select Command, connection String) Dim data As New Data Table() data. Storing sensitive information, such as a password, within the connection string can affect the security of your application. 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.