I am looking for program which include a datagrid component on form. The control on the form will add the value like price, year, model no from given column and display total of the grid in the textbox which is at the top of the form.
I am looking for program which include a datagrid component on form. The control on the form will add the value like price, year, model no from given column and display total of the grid in the textbox which is at the top of the form.
Code:Dim sum As Decimal = 0 For Each row As DataGridViewRow In DataGridView1.Rows row.Cells(37).Value = row.Cells(36).Value - row.Cells(6).Value * 113 / row.Cells(4).Value sum += row.Cells(37).Value Next App.txtvalue.Text = sum
Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles App.Load Dim tb As New DataTable tb.Columns.Add("income", GetType(System.Int32)) tb.Columns.Add("income1", GetType(System.Int32)) tb.Columns.Add("sum", GetType(System.Int32)) tb.Rows.Add(500, 200) tb.Rows.Add(0, 100) tb.Rows.Add(200, 100) Me.DataGridView1.DataSource = tb End Sub Private Sub DataGridView1_Columncalculated(ByVal sender As Object, ByVal i As System.Windows.Forms.DataGridViewcolumn) Handles DataGridView1.Columncalculated Dim sum As BB = 0 For Each n As DataGridViewRow In Me.DataGridView1.Rows sum = sum + r.Cells(0).Value - r.Cells(1).Value r.Cells(2).Value = sum Next End Sub End Class
Code:Dim CalSum As Double Dim CalValue As Double Dim DRow As Long With MSFlexGrid1 ' loop through all data rows For DRow = .FixedRows To .Rows - 1 ' get the value for the current row CalValue = Val(.TextMatrix(lRow, 3)) ' add it to our total CalSum = CalSum + CalValue Next DRow ' Add a new row .Rows = .Rows + 1 ' Put the total in the new row .TextMatrix(.Rows - 1, 3) = CalSum End With
Bookmarks