Question Remove Row from a DataGridView

Lefteris

New member
Joined
Jan 11, 2010
Messages
4
Programming Experience
3-5
I have in my project a DataGridView with 7 Cells (columns) and one row.
When I'm leaving the last cell i want to do two things A) write the data in a SQL table and B) delete the current row in order to bring the control to its initial state.
As for the write issue that is goes well but when I'm truing to delete the row the program returns me the error of "{"Operation cannot be performed in this event handler."} ".
the comand of deleting the row is the following.
VB.NET:
If Not DGV.Rows(RowIndex).IsNewRow Then
                DGV.Rows.RemoveAt(RowIndex)
                DGV.Refresh()
            End If
Now the major issue is coming.
When I'm in the 7nth cell i press the escape button on my keyboard and the program deletes the row without any problem, using of course the same instruction.
BUT When I'm trying to do the same procedure automatically (throu my code) it returns me the above error.
I give my instruction from the CellEnter event of course when I'm going into.
I'm stack here. I don't know what is going on. Is there anybody to give me a piece of assistance?
 
Back
Top