
Eliminar filas de un DatagridView
Publicado por Edy (1 intervención) el 23/05/2015 18:44:43
Soy nuevo en VB.Net y estoy intentando hacer un pequeño sistema de facturacion. Lo que deseo hacer es eliminar la fila seleccionada del detalle de factura. Tengo una coleccion donde guardo los items de el datagridview. Aca el codigo:
De antemano Muchas gracias por la ayuda
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
Private Sub cmdAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAgregar.Click
For Each bp As producto In col_producto
If (cboProducto.Text = bp.pro_codigo) Then
With DataGridView1
.Rows.Add()
.Item(0, i).Value = bp.pro_codigo
.Item(1, i).Value = bp.pro_nombre
.Item(2, i).Value = txtCantidad.Text
.Item(3, i).Value = txtCantidad.Text * p.pro_valor
End With
i += 1
End If
Next
End Sub
'Con el boton de eliminar tengo este codigo
'solo me elimina la fila del datagridview pero el item sigue ahi y se guarda en la base de datos
Private Sub cmdEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminar.Click
Me.DataGridView1.Rows.Remove(Me.DataGridView1.CurrentRow)
End Sub
De antemano Muchas gracias por la ayuda
Valora esta pregunta


0