Public Sub DGVDeleteRecord(ByVal Cellindex As Int16, ByVal DGV As DataGridView) Try If DGV.CurrentCell.RowIndex = DGV.NewRowIndex.ToString Then Exit Sub ElseIf DGV.CurrentCell.ColumnIndex.ToString = Cellindex Then Dim msg As Short = MessageBox.Show("سيتم حذف القيد الحالي .. هل أنت متاكد؟", "تأكيد", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, _ MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading) If msg = 6 Then DGV.Rows.RemoveAt(DGV.CurrentCell.RowIndex) End If End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "خطأ") End Try End Sub
و في حدث (CellClick) للـ (DataGridView) ضع السطر التالي:
PHP كود :
Try If RetainedAmountsDGV.CurrentCell.ColumnIndex = 4 Then DGVDeleteRecord(4, DataGridView1) End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, msgboxtitle) End Try
مع تغيير فهرست العمود حسب ما موجود عندك اي تغيير الرقم (4) الى (Index) العمود المستخدم للحذف , و تغيير اسم (DataGridView1) الى الاسم المستخدم عندك للـ (DataGridView)