Results 1 to 4 of 4

Thread: [RESOLVED] DataGridView and RowValidating and Escape Delete Error

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Resolved [RESOLVED] DataGridView and RowValidating and Escape Delete Error

    Hi

    I have a bounded datagridview and have some code in row validating event. When i add a new line by writing something in one of the cells of the new row, and if in the middle of the process i wish to cancel this new row, if i use the escape key i get an exception, something like, Index (number of the removed row) does not have a value. After the exception the exception the row it's removed...

    How can i make the row validating to work correctly?

    I have this code in the start of rowValidating
    vb.net Code:
    1. If MyDataGridView.Rows(e.RowIndex) IsNot Nothing AndAlso Not MyDataGridView.Rows(e.RowIndex).IsNewRow Then
    2. '...code..
    3. End If

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  2. #2

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: DataGridView and RowValidating and Escape Delete Error

    No one?

    Thanks

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,686

    Re: DataGridView and RowValidating and Escape Delete Error

    Have you checked e.Cancel in RowValidating

  4. #4

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: DataGridView and RowValidating and Escape Delete Error

    Hehehe
    Sure I checked, that's the main property of the row validating...

    Solved the problem, just added another property to the IF statement, the IsCurrentRowDirty...
    MSDN Info

    Thanks

    Rate People That Helped You
    Mark Thread Resolved When Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width