Public Class frmGrid
Private Sub frmGrid_Load(sender As Object, e As EventArgs) Handles MyBase.Load
carga()
End Sub
Private Sub carga()
DataGridView1.ColumnCount = 4
DataGridView1.Columns(0).Name = "Marca"
DataGridView1.Columns(1).Name = "Modelo"
DataGridView1.Columns(2).Name = "Year"
DataGridView1.Columns(3).Name = "MSRP"
Dim dato(4) As String
dato(0) = "Toyota"
dato(1) = "Prius"
dato(2) = "2020"
dato(3) = "18000"
DataGridView1.Rows.Add(dato)
dato(0) = "Toyota"
dato(1) = "RAV 4"
dato(2) = "2019"
dato(3) = "19000"
DataGridView1.Rows.Add(dato)
dato(0) = "Toyota"
dato(1) = "HighLander"
dato(2) = "2018"
dato(3) = "19555"
DataGridView1.Rows.Add(dato)
dato(0) = "Dodge"
dato(1) = "Charger"
dato(2) = "2017"
dato(3) = "18555"
DataGridView1.Rows.Add(dato)
End Sub
Private Sub btnObtener_Click(sender As Object, e As EventArgs) Handles btnObtener.Click
txtPrecio.Text = DataGridView1.Item(3, 2).Value
End Sub
Private Sub btnFila_Click(sender As Object, e As EventArgs) Handles btnFila.Click
Dim cad As String
cad = DataGridView1.SelectedRows(0).Cells(0).Value + DataGridView1.SelectedRows(0).Cells(1).Value
cad += DataGridView1.SelectedRows(0).Cells(2).Value + DataGridView1.SelectedRows(0).Cells(3).Value
txtPrecio.Text = cad
End Sub
Private Sub btnEliminar_Click(sender As Object, e As EventArgs) Handles btnEliminar.Click
DataGridView1.Rows.RemoveAt(2)
End Sub
End Class
No hay comentarios:
Publicar un comentario