DataGridView vb2010 y access
Publicado por Jose (2 intervenciones) el 22/11/2019 19:56:30
Hola amigos, me presento mi nombre es Jose y actualmente estoy estudiando desarrollo de software. Voy comenzando en la programacion y ahora tengo una tarea que llevo dias tratando de sacar adelante pero no puedo y estoy totalmente desesperado.
El problema es el siguiente: En un formulario de visual 2010 tengo dos DataGridView, en el primero tengo cargada la informacion de una base de datos que ya esta vinculada correctamente sin embargo tengo un boton de agregar al DataGridView2 el registro seleccionado y uno de quitar el registro DataGridView2 y regresarlo al 1. El problema es que para pasarlo del 1 al 2 si funciona pero cuando trato de regresarlo del 2 al 1 es cuando todo falla me dice "No se pueden agregar filas mediante programación a la colección de filas de DataGridView cuando el control está enlazado a datos."
NECESITO SU AYUDA YA NO TENGO IDEA DE QUE HACER Y LLEVO DIAS VIENDO LIBROS PERO NO ENCUENTRO DATO ALGUNO DE COMO HACERLO O NO LO APLICO BIEN.
Este es mi codigo del boton de agregar el cual si funciona pero el de regresar lo intente hacer de forma inversa y definitivamente no es posible.
CODIGO BOTON DE AGREGAR DGVW1 (Enlazado a BD Access) a DGVW2 (local sin enlace a bd)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE As String
RFC = entrada(0, entrada.CurrentRow.Index).Value
NOMBRE = entrada(1, entrada.CurrentRow.Index).Value
CATEGORIA = entrada(2, entrada.CurrentRow.Index).Value
STATUS = entrada(3, entrada.CurrentRow.Index).Value
OBSERVA = entrada(4, entrada.CurrentRow.Index).Value
GAFETE = entrada(5, entrada.CurrentRow.Index).Value
salida.Rows.Add(RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE)
entrada.Rows.RemoveAt(entrada.CurrentRow.Index)
End Sub
End Class
CODIGO BOTON QUITAR DE DGVW2 A DGVW1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE As String
RFC = salida(0, salida.CurrentRow.Index).Value
NOMBRE = salida(1, salida.CurrentRow.Index).Value
CATEGORIA = salida(2, salida.CurrentRow.Index).Value
STATUS = salida(3, salida.CurrentRow.Index).Value
OBSERVA = salida(4, salida.CurrentRow.Index).Value
GAFETE = salida(5, salida.CurrentRow.Index).Value
entrada.Rows.Add(RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE)
salida.Rows.RemoveAt(salida.CurrentRow.Index)
End Sub
End Class



El problema es el siguiente: En un formulario de visual 2010 tengo dos DataGridView, en el primero tengo cargada la informacion de una base de datos que ya esta vinculada correctamente sin embargo tengo un boton de agregar al DataGridView2 el registro seleccionado y uno de quitar el registro DataGridView2 y regresarlo al 1. El problema es que para pasarlo del 1 al 2 si funciona pero cuando trato de regresarlo del 2 al 1 es cuando todo falla me dice "No se pueden agregar filas mediante programación a la colección de filas de DataGridView cuando el control está enlazado a datos."
NECESITO SU AYUDA YA NO TENGO IDEA DE QUE HACER Y LLEVO DIAS VIENDO LIBROS PERO NO ENCUENTRO DATO ALGUNO DE COMO HACERLO O NO LO APLICO BIEN.
Este es mi codigo del boton de agregar el cual si funciona pero el de regresar lo intente hacer de forma inversa y definitivamente no es posible.
CODIGO BOTON DE AGREGAR DGVW1 (Enlazado a BD Access) a DGVW2 (local sin enlace a bd)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE As String
RFC = entrada(0, entrada.CurrentRow.Index).Value
NOMBRE = entrada(1, entrada.CurrentRow.Index).Value
CATEGORIA = entrada(2, entrada.CurrentRow.Index).Value
STATUS = entrada(3, entrada.CurrentRow.Index).Value
OBSERVA = entrada(4, entrada.CurrentRow.Index).Value
GAFETE = entrada(5, entrada.CurrentRow.Index).Value
salida.Rows.Add(RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE)
entrada.Rows.RemoveAt(entrada.CurrentRow.Index)
End Sub
End Class
CODIGO BOTON QUITAR DE DGVW2 A DGVW1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE As String
RFC = salida(0, salida.CurrentRow.Index).Value
NOMBRE = salida(1, salida.CurrentRow.Index).Value
CATEGORIA = salida(2, salida.CurrentRow.Index).Value
STATUS = salida(3, salida.CurrentRow.Index).Value
OBSERVA = salida(4, salida.CurrentRow.Index).Value
GAFETE = salida(5, salida.CurrentRow.Index).Value
entrada.Rows.Add(RFC, NOMBRE, CATEGORIA, STATUS, OBSERVA, GAFETE)
salida.Rows.RemoveAt(salida.CurrentRow.Index)
End Sub
End Class
Valora esta pregunta


0