20-10-18, 01:11 AM
(20-10-18, 12:37 AM)rnmr كتب : جرب هذا
احذف Button27_Click فليس من متطلبات التراجع Undo
أما Button20_Click فيبدو أنه يوجد تكرار لنفس الاسم لديك
حذفته أخي الكريم rnmr ، لايوجد أخطاء في الكود لكن سُبحان الله لا يعمل عند الضغط على الزر، هذا الكود بعد التصحيح :
كود :
Public Class Form2
#Region " DataGridViewUndoStack "
Dim DataGridViewUndoStack As New Stack(Of undo)
Structure undo
Dim rows As Integer ' عدد الأسطر
Dim row As Integer ' رقم السطر
Dim col As Integer ' رقم العمود
Dim val As Object ' قيمة الخلية
End Structure
Private Sub DataGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DataGridView1.CellBeginEdit
Dim o As New undo
o.rows = DataGridView1.Rows.Count
o.row = DataGridView1.CurrentCell.RowIndex
o.col = DataGridView1.CurrentCell.ColumnIndex
o.val = DataGridView1.CurrentCell.Value
DataGridViewUndoStack.Push(o)
End Sub
Private Sub DataGridViewDoUndo() ' التراجع
If DataGridViewUndoStack.Count > 0 Then
Dim o As New undo
o = DataGridViewUndoStack.Pop
Me.DataGridView1.Rows(o.row).Cells(o.col).Value = o.val
Me.DataGridView1.CurrentCell = DataGridView1.Rows(o.row).Cells(o.col)
Do While DataGridView1.Rows.Count > o.rows
DataGridView1.Rows.RemoveAt(If(DataGridView1.AllowUserToAddRows, DataGridView1.Rows.Count - 2, DataGridView1.Rows.Count - 1))
Loop
End If
End Sub
Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
DataGridViewDoUndo()
End Sub
#End Region
عن أبي هريرة - رضي الله عنه - قال: قال رسول الله - صلى الله عليه وسلم -: ((كلمتان خفيفتان على اللسان، ثقيلتان في الميزان، حبيبتان إلى الرحمن: سبحان الله وبحمده، سبحان الله العظيم))؛ متفق عليه.
