Results 1 to 2 of 2

Thread: Datagridview _CellValidating question

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2008
    Posts
    34

    Datagridview _CellValidating question

    I have a datagridview and in the _CellValidating event I am checking a cell to make sure it is filled in. If it is not, I want to stop editing, display a msgbox, and highlight the particular cell. Here is my code :
    Code:
     
    If e.ColumnIndex = 2 Then
        If e.FormattedValue = "" Then
            If Me.dgvFish.IsCurrentCellDirty Then
                MsgBox("Sample Number is a required field.")
                Me.dgvFish.EndEdit()
                e.Cancel = True
                Me.dgvFish.Rows(e.RowIndex).Cells(2).Style.BackColor = Color.Aquamarine
            End If
        End If
    End If
    For some reason, I can't get the cell's backcolor to be filled in. Any suggestions ? Thanks.
    Last edited by bfoley; Mar 11th, 2010 at 03:42 PM.

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