• Viernes 19 de Abril de 2024, 11:38

Autor Tema:  Problema al agregar fila en datagridview  (Leído 1726 veces)

blusky

  • Miembro activo
  • **
  • Mensajes: 35
    • Ver Perfil
Problema al agregar fila en datagridview
« en: Miércoles 6 de Abril de 2011, 23:43 »
0
hola a todos!!!!

disculpen tengo un problema y talvez me puedan ayudar. no se que es lo malo q tengo en mi codigo.
quiero agregar una fila en el detalle de factura(se agrega la primera vez los datos) pero ya despues solo me agrega filas vacias!!!

no se a que se debe. espero me den una mano11

gracias

If Me.DataGridView1.Rows.Count > 0 Then
                If Me.cboProducto.SelectedValue = Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1).Cells(0).Value Then
                    MsgBox("Producto ya agregado, por favor seleccione otro", MsgBoxStyle.Critical, "Error")
                Else
                 
                    Me.DataGridView1.Rows(Me.DataGridView1.RowCount - 1).Cells(0).Value = Me.cboProducto.SelectedValue
                    Me.DataGridView1.Rows(Me.DataGridView1.RowCount - 1).Cells(1).Value = Me.txtCantidadPedida.Value
                    Me.DataGridView1.Rows(Me.DataGridView1.RowCount - 1).Cells(2).Value = Me.txtPrecioUnitario.Text.ToString
                    Me.DataGridView1.Rows(Me.DataGridView1.RowCount - 1).Cells(3).Value = Me.txtMonto.Text
                 
                    Me.DataGridView1.Rows.Add()
                End If