Results 1 to 4 of 4

Thread: Disable cell validation on form DataGridView

  1. #1
    Join Date
    Jan 2009
    Posts
    38

    Disable cell validation on form DataGridView

    Hi,
    Some of the columns in my database have format = N2
    DataSource is an ArrayList.
    I dot want any validation if someone enters invalid value in the column Since it gives problem when i try to close the window in such case.
    So how can i disable this validation? Don't want to use any close button too.

    Please help.

  2. #2
    Join Date
    May 2008
    Posts
    115

    Re: Disable cell validation on form DataGridView

    Did you try catching the Form Closing event and setting EventArgs Cancel
    value to false?

    http://msdn2.microsoft.com/en-us/library/ms229603.aspx

  3. #3
    Join Date
    May 2008
    Posts
    63

    Re: Disable cell validation on form DataGridView

    Try something like this:

    Code:
    Private Sub EquipmentValidationByCell(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles dgvEquipment.CellValidating
    
    strCellESN = e.FormattedValue
    
    If dgvEquipment.Columns(e.ColumnIndex).Name = "ESNDataGridViewTextBoxColumn" Then
    
    If EquipmentNumberValidation(strCellESN) Then
    
    dgvEquipment.Rows(e.RowIndex).ErrorText = "Invalid ESN - please correct"
    
    e.Cancel = True
    
    End If
    
    End If
    
    End Sub
    Hope this helps you!

  4. #4
    Join Date
    May 2008
    Posts
    40

    Re: Disable cell validation on form DataGridView

    That's exactly what the CellValidating event is for. You're supposed to set e.Cancel to True if the data fails validation and that prevents the data being committed.

Similar Threads

  1. Avoid Copy paste over Data Validation cell
    By Bryant in forum Software Development
    Replies: 7
    Last Post: 15-07-2011, 10:44 AM
  2. How to use Form Validation in JavaScript?
    By Dilbert in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 08:30 PM
  3. Problem of javascript and form with validation key entry
    By Sandy22 in forum Software Development
    Replies: 3
    Last Post: 16-10-2009, 04:51 PM
  4. How to use datagridview readonly cell
    By Ground 0 in forum Windows Software
    Replies: 3
    Last Post: 29-07-2009, 12:44 PM
  5. How to resize cell in DataGridView
    By Ebadaah in forum Software Development
    Replies: 3
    Last Post: 10-06-2009, 06:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,549,908.15169 seconds with 17 queries