hellow and and hi iam developing billing system in which i have used gridview control with three columns named Description,qty,price and total code given below it works fine but problem is when i edit any cell of datagrid a new row inserted automatically is there any property or way by the mean of which new row is inserted only when enter key is pressed "DgvBill.Rows.Add()" by this code new row will be inserted and reason i want to add new row by pressing enter key is only because of handling empty cell if any required cell is empty then it should keep focus on this row only this simple what i want thxxx
Private Sub DgvBill_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DgvBill.KeyUp
Try
Dim qty As Integer = 0
Dim price As Integer = 0
Dim total As Integer = 0
Dim j As Integer = 0
If e.KeyCode = Keys.Enter Then
For j = 0 To DgvBill.RowCount - 2
If DgvBill.Item("ClmQty", j).Value = "" Then
MsgBox("PLEASE ENTER QTY VALUE")
DgvBill.CurrentCell = DgvBill.Item("ClmQty", j)
DgvBill.BeginEdit(True)
Return
End If
If DgvBill.Item("ClmPrice", j).Value = "" Then
MsgBox("PLEASE ENTER PRICE VALUE")
DgvBill.CurrentCell = DgvBill.Item("ClmPrice", j)
DgvBill.BeginEdit(True)
Return
End If
qty = CInt(DgvBill.Item("ClmQty", j).Value.ToString)
price = CInt(DgvBill.Item("ClmPrice", j).Value.ToString)
total = qty * price
DgvBill.Item("ClmTotal", j).Value = total
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub