 
			
				02/06/2011, 15:15
			
			
			     |  
        |     |    |    Fecha de Ingreso: junio-2011  
						Mensajes: 200
					  Antigüedad: 14 años, 5 meses Puntos: 17     |        |  
        Copiar Filas de un DGV a otro DGV        Hola soy nuevo en esto pero llevo un buen programando. tengo el siguiente problema: estoy usando dos datagridview uno de llena con una consulta que hago, pero a esta consulta le agrege una columno con checkbox y el problema es aque no he podido hacer que cuando seleccione varios checkbox y le de al booton aceptar me copie esas filas al otro datagridview2. ayudemne porfavor. mi codigo es el siguiente:   
Imports System.Data.OleDb   
Public Class ClientesFacturacion 
'Code Snippet 
Dim fecha_inicio As String 
Dim fecha_final As String   
Private Sub ClientesFacturacion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
End Sub 
'metodo para inserte una columna al final del DataGridView 
Private Sub Columna() 
Dim column As New DataGridViewCheckBoxColumn() 
With column 
.Name = "seleccion" 
.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells 
.FlatStyle = FlatStyle.Standard 
.CellTemplate = New DataGridViewCheckBoxCell() 
.CellTemplate.Style.BackColor = Color.Beige 
End With 
DataGridView1.Columns.Insert(0, column) 
End Sub   
'metodo para formar la tabla que se insertara en el DataGridView 
Public Function GetDataAccess2007() As DataTable 
Dim Conn As New OleDbConnection 
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ADRIAN\Escritorio\ClientesFacuracion\FACT URACION.mdb" 
Dim sentenciaSql As String = "Select NUMCLIENTE, CLIENTE, NUMFACTURA, FECHA, TOTAL From FACTURAS WHERE " & _ 
"FECHA Between " & _ 
"# " + fecha_inicio + " # And # " + fecha_final + " #" 
Dim adaptador As New OleDbDataAdapter(sentenciaSql, Conn) 
Dim tablaDatos As New DataTable 
Try 
adaptador.Fill(tablaDatos) 
Columna() 
Catch ex As Exception 
End Try   
Return tablaDatos   
End Function   
Private Sub BotonBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotonBuscar.Click 
Me.DataGridView1.DataSource = GetDataAccess2007() 
BotonBuscar.Enabled = False 
'Columna() 
End Sub   
Private Sub BotonSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotonSalir.Click 
End 
End Sub 
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick   
If e.ColumnIndex = 0 Then 
If (Convert.ToBoolean(DataGridView1.Rows(e.RowIndex). Cells(0).Value)) Then   
DataGridView1.Rows(e.RowIndex).Cells(0).Value = False   
Else 
DataGridView1.Rows(e.RowIndex).Cells(0).Value = True 
'MsgBox("ha seleccionado este fila")   
End If 
End If 
End Sub   
Private Sub BotonAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotonAceptar.Click 
'BotonBuscar.Enabled = True 
DataGridView1.Enabled = False 
End Sub   
Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged 
fecha_final = DateTimePicker2.Value 
End Sub   
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged 
fecha_inicio = DateTimePicker1.Value 
End Sub   
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
BotonBuscar.Enabled = True 
'DataGridView1.Rows.Clear() 
' DataGridView1.clear() 
Me.DataGridView1.DataSource = Nothing 
Me.DataGridView1.Refresh() 
End Sub   
End Class           |