i trying remove current row datagridview not bound datasource , allowusertoaddrows property false.
i add rows datagridview using code
purchases.rows.add(selectedrow.cells(0).value, selectedrow.cells(1).value, selectedrow.cells(2).value, selectedrow.cells(6).value, "", "", selectedrow.cells(3).value
and use code remove current row
private sub purchases_cellendedit(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles purchases.cellendedit try if cdbl(purchases.currentrow.cells("column7").value) - cdbl(purchases.currentrow.cells(4).value) < 0 messagebox.show("quantity entered more total in stock " & vbnewline & vbnewline & purchases.currentrow.cells(1).value & " has " & stock & " in stock" & vbnewline & vbnewline & "increase stock level or reduce quantity entered or see system administrator help", "pharm app " & today.year & "", messageboxbuttons.ok, messageboxicon.information) purchases.rows.remove(purchases.currentrow) end if catch ex exception msgbox(ex.message) end try end sub
but error saying
"operation not valid because results in reentrant call setcurrentcelladdresscore function"
i tried remove last row with
purchases.rows.removeat(purchases.rowcount - 1)
and same error.
please newbie.
you have remove row after cellendedit event, replace line:
purchases.rows.remove(purchases.currentrow)
with this:
me.begininvoke(new action(sub() purchases.rows.remove(purchases.currentrow)))
Comments
Post a Comment