18-03-22, 07:16 PM
(11-03-22, 07:05 AM)حسين ادريس كتب : اتفضل الكود ي غالىجزاك الله خير الجزاء
مطلوب داتا جريد فيو1 بالفروم رقم 1
ومديول
انسخ هذا الكود
كود :
Imports System.Data.OleDb
Public Class Form1
Dim dt_cust As New DataTable
Dim da As OleDbDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
da = New OleDbDataAdapter("select * from mm", con)
da.Fill(dt_cust)
DataGridView1.DataSource = dt_cust
End Sub
Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
'e.SuppressKeyPress = False
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
Dim cmd As New OleDbCommandBuilder(da)
Try
da.Update(dt_cust)
con.Close()
MsgBox("تمت التعديل بنجاح")
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
End If
End Sub
ممكن تعمل نموذج بهذا الكود لو سمحت

