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

نسخة كاملة : لو سمحتوا يا جماعه طلب جمع قيم خلايا عمود فى الداتا جريد فيو
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
العمود الرابع لو بدانا من 0 -1-2-3-4 
جربت اكواد كتير بيكون الجمع 0 مع العلم ان فى قيم فى الخلايا
لو سمحتوا تعديل الكود

PHP كود :
 Private Sub folderadd_Load(sender As ObjectAs EventArgsHandles MyBase.Load


        Me
.txtid.Focus()
 
       For i 0 To dgvprodac.Columns.Count 1
            dgvprodac
.Columns(i).SortMode DataGridViewColumnSortMode.NotSortable

        Next
       
        
'For i = 0 To dt.Rows.Count - 1
        ' 
   dgvprodac.Rows(i).DefaultCellStyle.BackColor = If(i Mod 2 0Color.AliceBlueColor.AntiqueWhite)
 
       'Next
        '
Dim sum As Integer 0
        
'For i As Integer = 0 To dgvprodac.Rows.Count - 1
        ' 
   sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
 
       'Next
        '
txttotal.Text sum.ToString()
 
       Dim Total As Integer 0As Integer 0
        While z 
dgvprodac.Rows.Count
            
'    sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
            Total += CInt(dgvprodac.Rows(z).Cells(4).Value)
            z += 1
        End While
        txttotal.Text = Total.ToString()

        Dim da As New OleDb.OleDbDataAdapter("select label from tab_pro", con)
        Dim dt As New DataTable
        pd = Me.BindingContext(dt)
        da.Fill(dt)
        Dim itms = dt.Rows.Cast(Of DataRow).Select(Function(x) x("label").ToString).ToArray
        Dim gh As New AutoCompleteStringCollection()
        gh.AddRange(itms)
        txtlabel.AutoCompleteCustomSource = gh
        txtlabel.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        txtlabel.AutoCompleteSource = AutoCompleteSource.CustomSource
      

        txtsailman.Text = fullname
        sorse()
        

        
        Try
            con.Open()
            sqlstr = "Select IIF(MAX(Id) IS NULL,0,MAX(Id)) + 1 AS maxId from TAB_OLDER"
            '
sqlstr "select max ((MAX(Id) IS NULL,0,MAX(Id))) +1 from [tab_older] "
 
           cmd = New OleDbCommand(sqlstrcon)
 
           txtnamper.Text cmd.ExecuteScalar()
 
 
            con
.Close()
 
       Catch ex As Exception
            MessageBox
.Show(ex.Message)
 
       End Try
 
     
    End Sub 
(19-06-17, 10:36 PM)نبيل كونكت كتب : [ -> ]العمود الرابع لو بدانا من 0 -1-2-3-4 
جربت اكواد كتير بيكون الجمع 0 مع العلم ان فى قيم فى الخلايا
لو سمحتوا تعديل الكود

PHP كود :
 Private Sub folderadd_Load(sender As ObjectAs EventArgsHandles MyBase.Load


        Me
.txtid.Focus()
 
       For i 0 To dgvprodac.Columns.Count 1
            dgvprodac
.Columns(i).SortMode DataGridViewColumnSortMode.NotSortable

        Next
       
        
'For i = 0 To dt.Rows.Count - 1
        ' 
   dgvprodac.Rows(i).DefaultCellStyle.BackColor = If(i Mod 2 0Color.AliceBlueColor.AntiqueWhite)
 
       'Next
        '
Dim sum As Integer 0
        
'For i As Integer = 0 To dgvprodac.Rows.Count - 1
        ' 
   sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
 
       'Next
        '
txttotal.Text sum.ToString()
 
       Dim Total As Integer 0As Integer 0
        While z 
dgvprodac.Rows.Count
            
'    sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
            Total += CInt(dgvprodac.Rows(z).Cells(4).Value)
            z += 1
        End While
        txttotal.Text = Total.ToString()

        Dim da As New OleDb.OleDbDataAdapter("select label from tab_pro", con)
        Dim dt As New DataTable
        pd = Me.BindingContext(dt)
        da.Fill(dt)
        Dim itms = dt.Rows.Cast(Of DataRow).Select(Function(x) x("label").ToString).ToArray
        Dim gh As New AutoCompleteStringCollection()
        gh.AddRange(itms)
        txtlabel.AutoCompleteCustomSource = gh
        txtlabel.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        txtlabel.AutoCompleteSource = AutoCompleteSource.CustomSource
      

        txtsailman.Text = fullname
        sorse()
        

        
        Try
            con.Open()
            sqlstr = "Select IIF(MAX(Id) IS NULL,0,MAX(Id)) + 1 AS maxId from TAB_OLDER"
            '
sqlstr "select max ((MAX(Id) IS NULL,0,MAX(Id))) +1 from [tab_older] "
 
           cmd = New OleDbCommand(sqlstrcon)
 
           txtnamper.Text cmd.ExecuteScalar()
 
 
            con
.Close()
 
       Catch ex As Exception
            MessageBox
.Show(ex.Message)
 
       End Try
 
     
    End Sub 

ما فهنت طلبك  بدك تجمع عمود بالداتا غريد ولا ماذا
(20-06-17, 12:44 AM)العواد الصغير كتب : [ -> ]
(19-06-17, 10:36 PM)نبيل كونكت كتب : [ -> ]العمود الرابع لو بدانا من 0 -1-2-3-4 
جربت اكواد كتير بيكون الجمع 0 مع العلم ان فى قيم فى الخلايا
لو سمحتوا تعديل الكود

PHP كود :
 Private Sub folderadd_Load(sender As ObjectAs EventArgsHandles MyBase.Load


        Me
.txtid.Focus()
 
       For i 0 To dgvprodac.Columns.Count 1
            dgvprodac
.Columns(i).SortMode DataGridViewColumnSortMode.NotSortable

        Next
       
        
'For i = 0 To dt.Rows.Count - 1
        ' 
   dgvprodac.Rows(i).DefaultCellStyle.BackColor = If(i Mod 2 0Color.AliceBlueColor.AntiqueWhite)
 
       'Next
        '
Dim sum As Integer 0
        
'For i As Integer = 0 To dgvprodac.Rows.Count - 1
        ' 
   sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
 
       'Next
        '
txttotal.Text sum.ToString()
 
       Dim Total As Integer 0As Integer 0
        While z 
dgvprodac.Rows.Count
            
'    sum += Convert.ToInt32(dgvprodac.Rows(i).Cells(4).Value)
            Total += CInt(dgvprodac.Rows(z).Cells(4).Value)
            z += 1
        End While
        txttotal.Text = Total.ToString()

        Dim da As New OleDb.OleDbDataAdapter("select label from tab_pro", con)
        Dim dt As New DataTable
        pd = Me.BindingContext(dt)
        da.Fill(dt)
        Dim itms = dt.Rows.Cast(Of DataRow).Select(Function(x) x("label").ToString).ToArray
        Dim gh As New AutoCompleteStringCollection()
        gh.AddRange(itms)
        txtlabel.AutoCompleteCustomSource = gh
        txtlabel.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        txtlabel.AutoCompleteSource = AutoCompleteSource.CustomSource
      

        txtsailman.Text = fullname
        sorse()
        

        
        Try
            con.Open()
            sqlstr = "Select IIF(MAX(Id) IS NULL,0,MAX(Id)) + 1 AS maxId from TAB_OLDER"
            '
sqlstr "select max ((MAX(Id) IS NULL,0,MAX(Id))) +1 from [tab_older] "
 
           cmd = New OleDbCommand(sqlstrcon)
 
           txtnamper.Text cmd.ExecuteScalar()
 
 
            con
.Close()
 
       Catch ex As Exception
            MessageBox
.Show(ex.Message)
 
       End Try
 
     
    End Sub 

ما فهنت طلبك  بدك تجمع عمود بالداتا غريد ولا ماذا
اه بالظبط عايز اجمع العمود الرابع فى الداتا فريد فيو
العمود الرابع ترتيبه 3


كود :
TextBox1.Text = (From row In DataGridView1.Rows Select CDbl(row.Cells(3).Value)).Sum()
الى الان ما فهمت ماذا تريد 
ولكن من اجل جمع عمود  مرر هذا الكود للداتا غريد مع مراعاة رقم الحقل والقيمة الفارغة والتكست وقد اخذتها 
من هذا المنتدى 
كود :
Public Sub sumcolimdatagridview(ByVal dvg As DataGridView, ByVal txtsum As TextBox, ByVal Col As String, ByVal Col1 As String) 'جمع عمود بالداتا غريد
       'اجراء جمع عمود بالداتا غريد فيو وياخذ اربعة معاملات
       'الاول الداتا غريد فيو
       'الثاني مربع نص من اجل الجمع
       'الثالث تحديد حقل الذا كان فارغا لا يتم جمع السجل الفارغ
       'الرابع الحقل المراد جمعه
       Try
           Dim sum As Decimal = 0 'تعريف متغير من نوع عملة
           For i As Integer = 0 To dvg.Rows.Count - 1 ' حلقة تكرار من اجل جمع كافة سجلات الحق المطلوب
               If Not dvg.Rows(i).Cells(Col).Value = Nothing Then
                   sum += Convert.ToDecimal(dvg.Rows(i).Cells(Col1).Value) 'عملية الجمع
               End If

           Next
           txtsum.Text = sum.ToString() 'اسناد قيمة المتغير للتكست بوكس
       Catch ex As Exception
           MsgBox("Can't load Web page" & vbCrLf & ex.Message)
       End Try

   End Sub
(20-06-17, 04:02 PM)حريف برمجة كتب : [ -> ]العمود الرابع ترتيبه 3


كود :
TextBox1.Text = (From row In DataGridView1.Rows Select CDbl(row.Cells(3).Value)).Sum()

الله ينور يا بشمهندس
تريد جمع  العمود رقم 4  الذي ترتيبه 3