منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : المساعدة في إيجاد حل كود للجريدفيو مرفق مثال
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الأخوة الافاضل في منتدى فيجول بيسك لكل العرب
أرجو المساعدة

السلام عليكم

مرفق لكم جزء من المشروع الخاص ارجو مساعدتي في كيفيه استخدام الـ DataGrid 
من خلال إضافة الاكواد المطلوبة في الصورة المرفقة على المشروع


مع أطيب تحياتي
PHP كود :
       For r As Integer 1 To 100
            d
.Rows.Add(r.ToString)
 
       Next
        Dim i 
As Integer 0
        For r 
As Integer 0 To d.Rows.Count 1
            i 
+= Val(d.Rows(r).Cells(0).Value)
 
       Next
        d
.Rows.Add("Total: " i.ToString
اخي سعود بارك الله فيك وجزاك الله الف خير ولكن الكود يعطي معي خطاء ياريت تطبيقه علي كل الاعمدة في المتال المرفق في حالة عرض الفورم وفي حالة البحث بين تارخين واسف علي تعبك وربي يجازيك كل الخير
هذا  الكلاس فوورم  بالكامل   أنسخ والصق فقط 

كود :
Imports System.Data.OleDb
Public Class Form1
   Dim ConStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\db.accdb"
   Dim Conn As New OleDbConnection(ConStr)
   Dim da As New OleDbDataAdapter
   Dim dt As New DataTable
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       dt.Clear()
       da = New OleDbDataAdapter("Select * from AAA", Conn)
       da.Fill(dt)
       DataGridView1.DataSource = dt
        DataGridView1.Columns(0).Visible = False


        Compute(DataGridView1)
    End Sub

    Private Sub B2DatesFind_Btn_Click(sender As Object, e As EventArgs) Handles B2DatesFind_Btn.Click
        Dim dtp1 As Date = DateTimePicker_from.Value
        Dim dtp2 As Date = DateTimePicker_to.Value
        dt.Clear()
        da = New OleDbDataAdapter("Select * from AAA where Date >= #" & dtp1.Year & "/" & dtp1.Month & "/" & dtp1.Day & "# and Date <= #" & dtp2.Year & "/" & dtp2.Month & "/" & dtp2.Day & "# order by Date ", Conn)
        da.Fill(dt)
        DataGridView1.DataSource = dt
        Conn.Close()

        TextBox1.Text = (From row In DataGridView1.Rows Select CDbl(row.Cells(2).Value)).Sum()
    End Sub






    Private Sub Compute(ByVal Dgv As DataGridView)

        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Value = "Total Is "
        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Style.BackColor = Color.Black
        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Style.ForeColor = Color.Gold

        Dim rw1 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(2).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(2).Value = rw1.Sum(Function(x As DataGridViewRow) x.Cells(2).Value)


        Dim rw2 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(3).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(3).Value = rw2.Sum(Function(x As DataGridViewRow) x.Cells(3).Value)


        Dim rw3 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(4).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(4).Value = rw3.Sum(Function(x As DataGridViewRow) x.Cells(4).Value)

    End Sub

End Class
(05-03-18, 11:46 AM)Abu Ehab كتب : [ -> ]هذا  الكلاس فوورم  بالكامل   أنسخ والصق فقط 

كود :
Imports System.Data.OleDb
Public Class Form1
   Dim ConStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\db.accdb"
   Dim Conn As New OleDbConnection(ConStr)
   Dim da As New OleDbDataAdapter
   Dim dt As New DataTable
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       dt.Clear()
       da = New OleDbDataAdapter("Select * from AAA", Conn)
       da.Fill(dt)
       DataGridView1.DataSource = dt
        DataGridView1.Columns(0).Visible = False


        Compute(DataGridView1)
    End Sub

    Private Sub B2DatesFind_Btn_Click(sender As Object, e As EventArgs) Handles B2DatesFind_Btn.Click
        Dim dtp1 As Date = DateTimePicker_from.Value
        Dim dtp2 As Date = DateTimePicker_to.Value
        dt.Clear()
        da = New OleDbDataAdapter("Select * from AAA where Date >= #" & dtp1.Year & "/" & dtp1.Month & "/" & dtp1.Day & "# and Date <= #" & dtp2.Year & "/" & dtp2.Month & "/" & dtp2.Day & "# order by Date ", Conn)
        da.Fill(dt)
        DataGridView1.DataSource = dt
        Conn.Close()

        TextBox1.Text = (From row In DataGridView1.Rows Select CDbl(row.Cells(2).Value)).Sum()
    End Sub






    Private Sub Compute(ByVal Dgv As DataGridView)

        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Value = "Total Is "
        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Style.BackColor = Color.Black
        Dgv.Rows(Dgv.Rows.Count - 1).Cells(1).Style.ForeColor = Color.Gold

        Dim rw1 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(2).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(2).Value = rw1.Sum(Function(x As DataGridViewRow) x.Cells(2).Value)


        Dim rw2 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(3).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(3).Value = rw2.Sum(Function(x As DataGridViewRow) x.Cells(3).Value)


        Dim rw3 = From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow.Cells(4).FormattedValue <> String.Empty
                  Select theRow


        Dgv.Rows(Dgv.Rows.Count - 1).Cells(4).Value = rw3.Sum(Function(x As DataGridViewRow) x.Cells(4).Value)

    End Sub

End Class

السلام عليكم 
مشكور أخي ابو ايهاب وجزاك الله الف خير كود الجمع شغال تمام  بس ممكن تطويره
ليشمل جميع الاعمدة الموجودة حتي لا يتم تكرار الكود لان يوجد لدي عدة أعمدة 

ولك من جزيل الشكر والعرفان

PHP كود :
Dim rw1 From theRow As DataGridViewRow In Dgv.Rows
                  Where theRow
.Cells(2).FormattedValue <> String.Empty
 
                 Select theRow

        Dgv
.Rows(Dgv.Rows.Count 1).Cells(2).Value rw1.Sum(Function(As DataGridViewRowx.Cells(2).Value