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

Data Grid View

The document describes the DataGridView object in Visual Basic, which displays data in rows and columns like a grid. It has properties like row and column count, and can access individual items using row and column indexes. DataGridView is used to calculate averages, totals for invoices, and averages of grades in a report card. It loops through rows and columns to perform calculations on the data in the grid.

Uploaded by

Javier Villegas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Data Grid View

The document describes the DataGridView object in Visual Basic, which displays data in rows and columns like a grid. It has properties like row and column count, and can access individual items using row and column indexes. DataGridView is used to calculate averages, totals for invoices, and averages of grades in a report card. It loops through rows and columns to perform calculations on the data in the grid.

Uploaded by

Javier Villegas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Objeto DataGridView

1. Concepto
Es un objeto que contiene datos dispuestos en FILAS y COLUMNAS,
Rejilla de Datos.
Col1 Col2 Col3
Fila1 Jose 53 1.67
Fila2 Jesus 33 1.80
Data : datos
Grid : rejilla
View : ver o presentar
2. Propiedades
Tiene las siguientes propiedades:
a) Total de las filas, DataGridView1.RowCount
b) Item, accede a cada item, pero con el número de COLUMNA y FILA.
DataGridView1.Item( columna , fila ).value
c) Las filas y columnas quedan enumeradas a partir del CERO, 0.

3. Aplicación
a) Hallar el promedio de la estatura de personas.
Nombre Estatura
1 Jose 1.67
2 Jesus 1.80

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim k, tot As Integer
Dim est, sum, prom As Single
tot = DataGridView1.RowCount - 1
For k = 0 To tot
est = DataGridView1.Item(1, k).Value
sum = sum + est
Next
Label1.Text = sum
prom = sum / tot
Label2.Text = Format(prom, "0.00")
End Sub
Factura:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim k, tot As Integer
Dim preunit, cant, costo, sum As Integer
tot = DataGridView1.RowCount - 1
sum = 0
For k = 0 To tot
preunit = DataGridView1.Item(1, k).Value
cant = DataGridView1.Item(2, k).Value
costo = preunit * cant
DataGridView1.Item(3, k).Value = costo
sum += costo
Next
Label3.Text = Format(sum, "0.00")
End Sub

Planilla de calificaciones:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim K, J, totfilas As Integer
Dim cal, sum As Integer
Dim prom As Single
totfilas = DataGridView1.RowCount - 1
For K = 0 To totfilas
sum = 0
For J = 1 To 5
cal = DataGridView1.Item(J, K).Value
sum += cal
prom = sum / 5
DataGridView1.Item(6, K).Value = Format(prom, "0.00")
Next
Next
End Sub

You might also like