• الإعلانات

    • فيصل الحربي

      تسجيل عضوية جديدة في المنتدى   01/31/2016

      السلام عليكم ورحمة الله وبركاته  عزيزي العضو الجديد :  حاليا رسالة الإيميل لتأكيد صحة إيميلكم تذهب للبريد العشوائي ( جاري حل المشكلة )  فإذا لم تجد رسالة التحقق من إيميلكم في صندوق الوارد لديكم إتجه للبريد العشوائي ( JUNK)  وقم بتفعيل إشتراككم من هناك   

البحث في المنتدى

Showing results for tags 'save on datagridview'.

  • البحث بالتاقات

    اكتب الكلمات المفتاحيه بينها علامه الفاصله
  • البحث بكاتب الموضوع

تم إيجاد 27 نتيجة

  1. السلام عليكم و رحمة الله   أريد الإضافة أو التعديل في الداتاجريدفيو ، و لم أفلح في تشغيل هذا الكود   أرجو مساعدتكم و لكم الشكر  Addrow.rar
  2. لدينا قاعدة بيانات متصلة بمشروع فيجوال بيزك 2010 به DataGrodView و نريد أن نجعل عمليات الحفظ و الحذف و التعديل و التنقل بين السجلات أسها باستخدام مفاتيح الكايبورد :   شكل الفورم :   الأكواد :   Imports System.Data.OleDbPublic Class Form1 '============================Visit Me==============================' ' You may use this Application for any purpose, as you wish . ' Don't forget to build your database as instructed at the tutorial ' link here : http://adonetaccess2003.blogspot.com/2011/11/datagridview-add-edit-delete-into.html'>http://adonetaccess2003.blogspot.com/2011/11/datagridview-add-edit-delete-into.html ' For any help using MS VB.Net along with any DB Engine, please ' Feel free to visit me here : http://adonetaccess2003.blogspot.com ' Or just : Google me ( Evry1falls - Your Issues ) ' ' Thanx again for using Evry1falls Solutions ' '==================================================================' Public CN As New OleDb.OleDbConnection Public RD As OleDbDataReader Public DBS As New DataSet Public Ckind As New OleDbCommand Public Akind As New OleDbDataAdapter Public CmDB As New OleDbCommandBuilder Public DkindS As New DataTable Public Rec As DataRow Public Frec() As DataRow Public N, I, CntRs, CntC As Integer Public SqlStr, xC As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim connectionString As String = "Provider=Microsoft.Ace.OleDB.12.0 ; Data Source = " & Application.StartupPath & "\MyDB.accdb" Dim sql As String = "SELECT * FROM Kinds" Dim connection As New OleDbConnection(connectionString) Dim dataadapter As New OleDbDataAdapter(sql, connection) Dim ds As New DataSet() connection.Open() dataadapter.Fill(ds, "Kinds") connection.Close() DG1.DataSource = ds DG1.DataMember = "Kinds" DG1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single DG1.CellBorderStyle = DataGridViewCellBorderStyle.Single DG1.Columns("Kind").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill DG1.Columns("kind").HeaderCell.Value = "Sort Of Items" Rec = Nothing Frec = Nothing PictureBox1.Hide() Label1.Text = "" End Sub Private Sub DG1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DG1.CellBeginEdit If CN.State = ConnectionState.Open Then CN.Close() CN.ConnectionString = "Provider=Microsoft.Ace.OleDB.12.0 ; Data Source = " & Application.StartupPath & "\MyDB.accdb" CN.Open() PictureBox1.Show() Label1.Text = "" PictureBox1.Image = My.Resources.loading SqlStr = "Select * from Kinds" Ckind.Connection = CN Ckind.CommandText = SqlStr With Akind .SelectCommand = Ckind .Fill(DBS, "Kinds") End With DkindS = DBS.Tables("Kinds") CntC = DG1.Rows.Count If DG1.Rows(DG1.CurrentCell.RowIndex).IsNewRow = False Then xC = DG1.CurrentCell.Value.ToString Else xC = Nothing End If End Sub Private Sub DG1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DG1.CellEndEdit If DG1.Rows.Count = CntC Then Frec = DkindS.Select("Kind = '" & xC & "'") If Frec.Length = 0 Then Exit Sub End If Rec = Frec(0) Rec.BeginEdit() Rec!Kind = DG1.Columns(0).DataGridView(0, DG1.CurrentCell.RowIndex).Value Rec.EndEdit() If DBS.HasChanges = True Then CmDB.DataAdapter = Akind Akind.Update(DBS, "Kinds") Label1.Text = "Editted Successfully" PictureBox1.Hide() End If Exit Sub End If SqlStr = "Select * from Kinds" Ckind.Connection = CN Ckind.CommandType = CommandType.Text Ckind.CommandText = SqlStr With Akind .SelectCommand = Ckind .Fill(DBS, "Kinds") End With DkindS = DBS.Tables("Kinds") If DG1.Columns(0).DataGridView(0, DG1.CurrentCell.RowIndex).Value Is DBNull.Value Then PictureBox1.Hide() Label1.Text = "لا يمكن اضافة نوع فارغ" Exit Sub End If PictureBox1.Show() Rec = DkindS.NewRow Rec!KIND = DG1.Columns(0).DataGridView(0, DG1.CurrentCell.RowIndex).Value DkindS.Rows.Add(Rec) If DBS.HasChanges = True Then CmDB.DataAdapter = Akind Akind.Update(DBS, "Kinds") Label1.Text = "تم التحديث" PictureBox1.Hide() End If End Sub Private Sub DG1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DG1.KeyDown If CN.State = ConnectionState.Open Then CN.Close() CN.ConnectionString = "Provider=Microsoft.Ace.OleDB.12.0 ; Data Source = " & Application.StartupPath & "\MyDB.accdb" CN.Open() If e.KeyCode = Keys.Delete Then If DG1.Rows.GetRowCount(DataGridViewElementStates.Visible) = 1 Then Label1.Text = "No Data Available" Exit Sub End If If DG1.Rows(DG1.CurrentRow.Index).IsNewRow = True Then Label1.Text = "Violation - Selected Couldn't be Deleted" Exit Sub End If Dim xc As String xc = DG1.Columns(0).DataGridView(0, DG1.CurrentCell.RowIndex).Value.ToString MsgBox(xc) SqlStr = "Delete From Kinds where (Kind) = '" & xc & "'" Ckind.Connection = CN Ckind.CommandText = SqlStr CntRs = Ckind.ExecuteNonQuery Label1.Text = (CntRs & " Record(S) Deleted Successfully") DG1.Rows.Remove(DG1.CurrentCell.OwningRow) DG1.Refresh() End If End SubEnd Class  المصدر الأصلى