close
    how to set focus a cell in datagridview in vb.net

    Does anybody call help me?


    I am trying to set focus a cell.


    I enter data in datagridview cell and then press tab to next cell. before enter next cell, I want to do some validation on the data entered in the first cell. if the data not validate value, clear the data and set focus to first cell.


    the code would me like this


    Private Sub DataGridView1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter

    If DataGridView1.Rows(0).Cells(0).Value <> Nothing Then
    DataGridView1.Rows(0).Cells(0).Selected = True
    DataGridView1.Rows(0).Cells(0).Value = ""
    'DataGridView1.CurrentCell = DataGridView1.Item(0, 0) ------ this give an error


    'Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore


    function.
    End If


    End Sub

    0  Views: 1565 Answers: 1 Posted: 13 years ago

    1 Answer

    Try here


    http://www.vbforums.com/showthread.php?588787-RESOLVED-Set-focus-in-a-specific-cell-of-a-datagridview



    Top contributors in Uncategorized category

     
    ROMOS
    Answers: 18061 / Questions: 154
    Karma: 1102K
     
    Colleen
    Answers: 47269 / Questions: 115
    Karma: 953K
     
    country bumpkin
    Answers: 11322 / Questions: 160
    Karma: 838K
     
    Benthere
    Answers: 2392 / Questions: 30
    Karma: 760K
    > Top contributors chart

    Unanswered Questions

    hay88tax
    Answers: 0 Views: 1 Rating: 0
    jiuyouwin
    Answers: 0 Views: 8 Rating: 0
    Nhà Đài HELLO88
    Answers: 0 Views: 4 Rating: 0
    ivip9ink
    Answers: 0 Views: 13 Rating: 0
    sunwin1tvv
    Answers: 0 Views: 5 Rating: 0
    Nhà Đài SKY88
    Answers: 0 Views: 5 Rating: 0
    Nhà Đài SKY88
    Answers: 0 Views: 7 Rating: 0
    11UU
    Answers: 0 Views: 9 Rating: 0
    > More questions...
    526791
    questions
    760274
    answers
    873838
    users