Hi ....


I want to add a new rows when cell leave event occurs.It shows error like Operation can not be performed in this event handler...

here is my code,


If PatientDataGridView.CurrentCell.ColumnIndex = 2 Then
PatientDataGridView.Rows.Add()
End If

Member Avatar for Huntondoom

why add a row when the current cell is located in the 3 column?
first of all this should be trigger like this:

Private Sub DataGridView1_CellLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
        If e.ColumnIndex = 2 Then
            DataGridView1.Rows.Add()
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.