Pasar filas aleatorias de un MSFlexGrid a otro MSFlexGrid
hola tengo una aplicacion en vb 6.0 donde tengo 2 MSFlexGrid uno tiene la informacion de la bd y el otro lo ocupo para pasar del primer MSFlexGrid esa informacion, tengo un codigo que si selecciono con shift toda al fila lo pasa, uso la tecla control para seleccionar por separado es decir si tengo 5 filas y quiero pasar la filas 1 ,4,5, las selecciono pero cuando le digo que lo pase no lo hace este es el codigo que ocupo para pasarlos de uno msflexgrid al otro
With MSFlexGrid2
' borra la grilla
.Clear
' si el rango es de una sola columna sale
If MSFlexGrid1.ColSel = MSFlexGrid1.Col Then
'.Rows = 1
' .Cols = MSFlexGrid1.Cols
Exit Sub
End If
' encabezado igual al MSFlexGrid1
.FormatString = MSFlexGrid1.FormatString
'Asigna la cantidad de filas seleccionadas del rango
.Rows = Abs(MSFlexGrid1.RowSel - MSFlexGrid1.Row) + 2
.FixedCols = MSFlexGrid1.FixedCols
.FixedRows = MSFlexGrid1.FixedRows
.Row = 1
.Col = 1
.RowSel = .Rows - 1
.ColSel = .Cols - 1
' copia los datos al otro flexgrid
.Clip = MSFlexGrid1.Clip
end with
y este es el codigo de la tecla control
Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = vbShiftMask Then m_booKeyShift = True
If Shift = vbCtrlMask Then m_booKeyCtrl = True
End Sub
Private Sub MSFlexGrid1_Keyup(KeyCode As Integer, Shift As Integer)
With MSFlexGrid1
m_booKeyCtrl = False
m_booKeyShift = False
End With
End Sub
Private Sub MSFlexGrid1_RowColChange()
With MSFlexGrid1
Static booBusy As Boolean
If m_booKeyShift Or booBusy Then Exit Sub
booBusy = True
Dim intThisCol As Integer, intThisRow As Integer
intThisCol = .Col
intThisRow = .Row
LockWindowUpdate .hwnd
If m_booKeyCtrl Then
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intThisRow
If .CellBackColor = .BackColorSel Then
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
Else
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
End If
Else
.Col = 1
.Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.FillStyle = flexFillRepeat
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intThisRow
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
End If
.Col = intThisCol
.Row = intThisRow
LockWindowUpdate 0&
booBusy = False
End With
End Sub
Private Sub MSFlexGrid1_SelChange()
With MSFlexGrid1
If Not m_booKeyShift Then Exit Sub
Dim intThisCol As Integer, intThisRow As Integer
intThisCol = .Col
intThisRow = .Row
Dim intNextCol As Integer, intNextRow As Integer
intNextCol = .ColSel
intNextRow = .RowSel
LockWindowUpdate .hwnd
'~~> Clear Screen
.Col = 1
.Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.FillStyle = flexFillRepeat
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
'~~> Update Multiline
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intNextRow
.FillStyle = flexFillRepeat
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
LockWindowUpdate 0&
Tag900:
.Col = intNextCol
.Row = intNextRow
End With
End Sub
Espero me puedan ayudar gracias
With MSFlexGrid2
' borra la grilla
.Clear
' si el rango es de una sola columna sale
If MSFlexGrid1.ColSel = MSFlexGrid1.Col Then
'.Rows = 1
' .Cols = MSFlexGrid1.Cols
Exit Sub
End If
' encabezado igual al MSFlexGrid1
.FormatString = MSFlexGrid1.FormatString
'Asigna la cantidad de filas seleccionadas del rango
.Rows = Abs(MSFlexGrid1.RowSel - MSFlexGrid1.Row) + 2
.FixedCols = MSFlexGrid1.FixedCols
.FixedRows = MSFlexGrid1.FixedRows
.Row = 1
.Col = 1
.RowSel = .Rows - 1
.ColSel = .Cols - 1
' copia los datos al otro flexgrid
.Clip = MSFlexGrid1.Clip
end with
y este es el codigo de la tecla control
Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = vbShiftMask Then m_booKeyShift = True
If Shift = vbCtrlMask Then m_booKeyCtrl = True
End Sub
Private Sub MSFlexGrid1_Keyup(KeyCode As Integer, Shift As Integer)
With MSFlexGrid1
m_booKeyCtrl = False
m_booKeyShift = False
End With
End Sub
Private Sub MSFlexGrid1_RowColChange()
With MSFlexGrid1
Static booBusy As Boolean
If m_booKeyShift Or booBusy Then Exit Sub
booBusy = True
Dim intThisCol As Integer, intThisRow As Integer
intThisCol = .Col
intThisRow = .Row
LockWindowUpdate .hwnd
If m_booKeyCtrl Then
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intThisRow
If .CellBackColor = .BackColorSel Then
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
Else
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
End If
Else
.Col = 1
.Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.FillStyle = flexFillRepeat
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intThisRow
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
End If
.Col = intThisCol
.Row = intThisRow
LockWindowUpdate 0&
booBusy = False
End With
End Sub
Private Sub MSFlexGrid1_SelChange()
With MSFlexGrid1
If Not m_booKeyShift Then Exit Sub
Dim intThisCol As Integer, intThisRow As Integer
intThisCol = .Col
intThisRow = .Row
Dim intNextCol As Integer, intNextRow As Integer
intNextCol = .ColSel
intNextRow = .RowSel
LockWindowUpdate .hwnd
'~~> Clear Screen
.Col = 1
.Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.FillStyle = flexFillRepeat
.CellBackColor = .BackColor
.CellForeColor = .ForeColor
'~~> Update Multiline
.Col = 1
.Row = intThisRow
.ColSel = .Cols - 1
.RowSel = intNextRow
.FillStyle = flexFillRepeat
.CellBackColor = .BackColorSel
.CellForeColor = .ForeColorSel
LockWindowUpdate 0&
Tag900:
.Col = intNextCol
.Row = intNextRow
End With
End Sub
Espero me puedan ayudar gracias