21-02-16, 09:31 PM
21-02-16, 09:46 PM
جرب الكود التالي ::
PHP كود :
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Dim iCol = DataGridView1.CurrentCell.ColumnIndex
Dim iRow = DataGridView1.CurrentCell.RowIndex
If iCol = DataGridView1.Columns.Count - 1 Then
If iRow < DataGridView1.Rows.Count - 1 Then
DataGridView1.CurrentCell = DataGridView1(0, iRow + 1)
End If
Else
DataGridView1.CurrentCell = DataGridView1(iCol + 1, iRow)
End If
End If
End Sub
22-02-16, 12:34 AM
تحتاج الى كودين
الاول: اذا لم يتم التعديل على الخلايا
الثاني: اذا تم التعديل على الخلايا
الاول: اذا لم يتم التعديل على الخلايا
PHP كود :
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Dim iCol = DataGridView1.CurrentCell.ColumnIndex
Dim iRow = DataGridView1.CurrentCell.RowIndex
If iCol = DataGridView1.Columns.Count - 1 Then
If iRow < DataGridView1.Rows.Count - 1 Then
DataGridView1.CurrentCell = DataGridView1(0, iRow + 1)
End If
Else
DataGridView1.CurrentCell = DataGridView1(iCol + 1, iRow)
End If
End If
End Sub
الثاني: اذا تم التعديل على الخلايا
PHP كود :
Private Sub DataGridView1_CellEndEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
Dim iCol = DataGridView1.CurrentCell.ColumnIndex
Dim iRow = DataGridView1.CurrentCell.RowIndex
If iCol = DataGridView1.Columns.Count - 1 Then
If iRow < DataGridView1.Rows.Count - 1 Then
DataGridView1.CurrentCell = DataGridView1(0, iRow + 1)
End If
Else
If iRow < DataGridView1.Rows.Count - 1 Then
SendKeys.Send("{up}")
End If
DataGridView1.CurrentCell = DataGridView1(iCol + 1, iRow)
End If
End Sub
23-02-16, 09:21 PM
(22-02-16, 12:34 AM)mazen.excel كتب : [ -> ]تحتاج الى كودين
الاول: اذا لم يتم التعديل على الخلايا
PHP كود :
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Dim iCol = DataGridView1.CurrentCell.ColumnIndex
Dim iRow = DataGridView1.CurrentCell.RowIndex
If iCol = DataGridView1.Columns.Count - 1 Then
If iRow < DataGridView1.Rows.Count - 1 Then
DataGridView1.CurrentCell = DataGridView1(0, iRow + 1)
End If
Else
DataGridView1.CurrentCell = DataGridView1(iCol + 1, iRow)
End If
End If
End Sub
الثاني: اذا تم التعديل على الخلايا
PHP كود :
Private Sub DataGridView1_CellEndEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
Dim iCol = DataGridView1.CurrentCell.ColumnIndex
Dim iRow = DataGridView1.CurrentCell.RowIndex
If iCol = DataGridView1.Columns.Count - 1 Then
If iRow < DataGridView1.Rows.Count - 1 Then
DataGridView1.CurrentCell = DataGridView1(0, iRow + 1)
End If
Else
If iRow < DataGridView1.Rows.Count - 1 Then
SendKeys.Send("{up}")
End If
DataGridView1.CurrentCell = DataGridView1(iCol + 1, iRow)
End If
End Sub
لكل من شارك فى اجابة اسئلتى خالص التحية و الاحترام
و عرفان بالجميل
اشكركم انتم و اسرة هذا المنتدى على ماقدتموه فى خدمة المبتدئين امثالى
21-03-16, 02:17 AM
مالمقصود بالتعديل او قبل التعديل؟ ولماذا الحاجة الى كودين ارجو التوضيح ان امكن مع الشكر
21-03-16, 01:46 PM
قد يكون المستخدم بحاجة الى تعديل البيانات الموجودة في خلايا الداتاجريد لذلك عند تعديل هذه البيانات في خلايا الداتاجريد، وعند الانتهاء من التعديل يتم الضغط انتر فينفذ كود التنقل
وقد لا يكون المستخدم بحاجة الى الدخول الى الخلية وتعديلها ، لذلك ينفذ كود التنقل بدون تعديل
انتبه الى مكان اجراء الكود
CellEndEdit
KeyDow
وقد لا يكون المستخدم بحاجة الى الدخول الى الخلية وتعديلها ، لذلك ينفذ كود التنقل بدون تعديل
انتبه الى مكان اجراء الكود
CellEndEdit
KeyDow