0% found this document useful (0 votes)
13 views

"Proveedor ": 'Acumular El Total 'Solo Calculamos Si Modificamos La Columna Definida

This document contains code for configuring and manipulating controls on a Windows form. It includes code to: - Set the number of rows in two data grid views when buttons are clicked or the form loads. - Populate the header cells of a data grid view with text based on values from text boxes when a button is clicked. - Name the columns of a data grid view. - Sum the values in a column of a data grid view and display the total in the last row when a button is clicked.

Uploaded by

Xiomy Arboleda
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

"Proveedor ": 'Acumular El Total 'Solo Calculamos Si Modificamos La Columna Definida

This document contains code for configuring and manipulating controls on a Windows form. It includes code to: - Set the number of rows in two data grid views when buttons are clicked or the form loads. - Populate the header cells of a data grid view with text based on values from text boxes when a button is clicked. - Name the columns of a data grid view. - Sum the values in a column of a data grid view and display the total in the last row when a button is clicked.

Uploaded by

Xiomy Arboleda
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.

Load End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick DataGridView1.RowCount = 5 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click DataGridView3.ColumnCount = TextBox1.Text DataGridView3.RowCount = TextBox2.Text Dim rowNumber As Integer = 1 For Each row As DataGridViewRow In DataGridView3.Rows If row.IsNewRow Then Continue For row.HeaderCell.Value = "Proveedor " & rowNumber rowNumber = rowNumber + 1 If rowNumber = TextBox2.Text Then row.HeaderCell.Value = "Demanda " End If Next DataGridView3.AutoResizeRowHeadersWidth( _ DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders) DataGridView3.Columns(0).Name = "Aeropuerto1" DataGridView3.Columns(1).Name = "Aeropuerto2" DataGridView3.Columns(2).Name = "Aeropuerto3" DataGridView3.Columns(3).Name = "Oferta" End Sub Private Sub DataGridView3_CellContentClick_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellContentClick End Sub Private Columna As Integer = 3 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim Total As Integer = 0 'Acumular el total Dim UltimaFila As Integer = Me.DataGridView3.Rows.Count 'Solo calculamos si modificamos la columna definida If Me.DataGridView3.CurrentCell.ColumnIndex = Columna Then For Each row As DataGridViewRow In Me.DataGridView3.Rows If row.Index < UltimaFila - 1 Then Total += row.Cells(Columna).Value Next Me.DataGridView3.Rows(UltimaFila - 1).Cells(Columna).Value = Total.ToString End If

MsgBox("no asi no ")

End Sub

You might also like