-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
90 lines (72 loc) · 2.48 KB
/
Form1.cs
File metadata and controls
90 lines (72 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataGridView2
{
public partial class Form1 : Form
{
private double total = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//DataGridViewColumn codigo = new DataGridViewColumn();
//codigo.HeaderText = "Codigo";
//codigo.CellTemplate = new DataGridViewTextBoxCell();
////Platillas para Texto
//codigo.ReadOnly = true;
//DataGridViewColumn descripcion = new DataGridViewColumn();
//descripcion.HeaderText = "Descripcion Producto";
//descripcion.CellTemplate = new DataGridViewTextBoxCell();
////Platillas para Texto
//codigo.ReadOnly = true;
//dGVProductos.Columns.Add(codigo);
//dGVProductos.Columns.Add(descripcion);
////Se agrega una columna
///
lblTotalProductos.Text = "Cantidad de Productos:";
}
private void dGVProductos_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void btnIngresar_Click(object sender, EventArgs e)
{
total = 0;
dGVProductos.Rows.Add(txtCodigo.Text, txtDP.Text, txtPrecio.Text);
for(int i = 0; i<dGVProductos.Rows.Count-1;i++)
{
total = total + double.Parse(dGVProductos.Rows[i].Cells[2].Value.ToString());
}
txtTotalCompra.Text = "" + total;
lblTotalProductos.Text = "Cantidad de Productos:" + "" + (dGVProductos.Rows.Count - 1);
}
private void btnEliminar_Click(object sender, EventArgs e)
{
try
{
dGVProductos.Rows.RemoveAt(dGVProductos.CurrentCell.RowIndex);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//Metodo de la coleccion Rows
//Propiedad RowIndex: Devuelve el indice de la fila.
}
private void btnLimpiar_Click(object sender, EventArgs e)
{
txtCodigo.Clear();
txtDP.Clear();
txtPrecio.Clear();
txtTotalCompra.Clear();
}
}
}