Ver Mensaje Individual
  #13 (permalink)  
Antiguo 14/09/2012, 12:17
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 11 meses
Puntos: 220
Respuesta: ID en DataGridview

Bueno el código que te puse primero esta bien lo que sucede es que tienes habilitado la opcion AllowUserToAddRows en TRUE es por esto el motivo que se salta de linea y te genera error al agregar

PRIMERA OPCION = DESHABILITA EL AllowUserToAddRows Y TODO TE VA A SALIR OK

Código vb:
Ver original
  1. Dim total as Integer
  2. Dim row as DataGridViewRow
  3.  
  4. DataGridView1.Rows.Add(1)
  5.  
  6. total = DataGridView1.Rows.Count
  7. row = DataGridView1.Rows(total-1)
  8.  
  9. row.Cells(0).Value = txtcantidadd.Text
  10. row.Cells(1).Value = cboproducto.Text
  11. row.Cells(1).Tag = cboproducto.Value
  12. row.Cells(2).Value = cboproveedor.Text
  13. row.Cells(2).Tag = cboproveedor.Value
  14. row.Cells(3).Value = cboserial.Text
  15. row.Cells(3).Tag= cboserial.Value
  16. row.Cells(4).Value = txtcaracteristicas.Text

SEGUNDA OPCION = DEJA EL AllowUserToAddRows TAL COMO ESTA ES DECIR EN TRUE

Código vb:
Ver original
  1. Dim total as Integer
  2. Dim row as DataGridViewRow
  3. *
  4. total = DataGridView1.Rows.Count
  5.  
  6. DataGridView1.Rows.Add(1)
  7.  
  8. row = DataGridView1.Rows(total-1)
  9. *
  10. row.Cells(0).Value = txtcantidadd.Text
  11. row.Cells(1).Value = cboproducto.Text
  12. row.Cells(1).Tag = cboproducto.Value
  13. row.Cells(2).Value = cboproveedor.Text
  14. row.Cells(2).Tag = cboproveedor.Value
  15. row.Cells(3).Value = cboserial.Text
  16. row.Cells(3).Tag= cboserial.Value
  17. row.Cells(4).Value = txtcaracteristicas.Text

Si te das cuenta solo he cambiado la posicion del total y listo

Saludos
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones