السلام عليكم اعضاء الجروب الكرام ، لدي استفسار بسيط كيف اضع زر داخل الجريد فيو اول كل صف في شبكة الجريد وذلك لحذف الصف من الجريد فيو وقاعدة البيانات .... وشكرا
1. اضف عمود الى الكرد (Button).
2. في حذث (Cell_Click) في الكرد فيود اكتب الكود التالي :
PHP كود :
If datagridveiw1.CurrentCell.ColumnIndex = 0 Then Result = MessageBox.Show("هل انت متأكد من عملية الحذف", msgtitle, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly) If Result = DialogResult.Yes Then Dim deletecmd As New SqlCommand("Dlete From Table1 where id=" & datagridview.CurrentRow.Cells(1).Value, con) con.Open() deletecmd.ExecuteNonQuery() con.Close() Me.Table1TableAdapter.FillBy(Me.DataSet.Table1) MsgBox("تم حذف القيد بنجاح", MsgBoxStyle.Information, msgtitle) End If
مع تغيير اسم الجدول (Table1) والحقل (id) كما موجود عند في قاعدة البيانات
كما ويجب ملاحظة تغيير السطر التالي