Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/07/2006, 07:37
jorevale
Invitado
 
Mensajes: n/a
Puntos:
MSHFlexGrid Paginado

Saludos amigos

¿Alguien sabe como hacer un MSHFlexGrid Paginado?

Nota: Cuando creamos un MSHFlexGrid con el asistente en VB6, el código es el que abajo aparece, pero no sé que debo hacer para paginar esto.

Gracias



Private Const MARGIN_SIZE = 60 ' en twips
' variables para permitir el orden de columnas
Private m_iSortCol As Integer
Private m_iSortType As Integer

' variables para arrastrar columnas
Private m_bDragOK As Boolean
Private m_iDragCol As Integer
Private xdn As Integer, ydn As Integer

Private Sub Form_Load()

datPrimaryRS.Visible = False

With MSHFlexGrid1

.Redraw = False
' establecer anchos de columna de cuadrícula
.ColWidth(0) = -1
.ColWidth(1) = -1
.ColWidth(2) = -1
.ColWidth(3) = -1
.ColWidth(4) = -1
.ColWidth(5) = -1

' establecer tipo de cuadrícula
.AllowBigSelection = True
.FillStyle = flexFillRepeat

' encabezado en negrita
.Row = 0
.Col = 0
.RowSel = .FixedRows - 1
.ColSel = .Cols - 1
.CellFontBold = True

.AllowBigSelection = False
.FillStyle = flexFillSingle
.Redraw = True

End With

End Sub

Private Sub MSHFlexGrid1_DragDrop(Source As Control, X As Single, Y As Single)

If m_iDragCol = -1 Then Exit Sub ' no se estaba arrastrando
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub

With MSHFlexGrid1
.Redraw = False
.ColPosition(m_iDragCol) = .MouseCol
.Redraw = True
End With

End Sub

Private Sub MSHFlexGrid1_MouseDown(Button As Integer, shift As Integer, X As Single, Y As Single)

If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub

xdn = X
ydn = Y
m_iDragCol = -1 ' borrar indicador de arrastre
m_bDragOK = True

End Sub

Private Sub MSHFlexGrid1_MouseMove(Button As Integer, shift As Integer, X As Single, Y As Single)

' probar si se debe iniciar el arrastre
If Not m_bDragOK Then Exit Sub
If Button <> 1 Then Exit Sub ' botón incorrecto
If m_iDragCol <> -1 Then Exit Sub ' ya se está arrastrando
If Abs(xdn - X) + Abs(ydn - Y) < 50 Then Exit Sub ' no se ha movido suficiente
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub ' hay que arrastrar el encabezado

' si se llega aquí, iniciar el arrastre
m_iDragCol = MSHFlexGrid1.MouseCol
MSHFlexGrid1.Drag vbBeginDrag

End Sub

Private Sub MSHFlexGrid1_MouseUp(Button As Integer, shift As Integer, X As Single, Y As Single)

m_bDragOK = False

End Sub

Private Sub MSHFlexGrid1_DblClick()

Dim i As Integer

' sólo ordena cuando se hace clic en una fila
If MSHFlexGrid1.MouseRow >= MSHFlexGrid1.FixedRows Then Exit Sub

i = m_iSortCol ' guarda la columna antigua
m_iSortCol = MSHFlexGrid1.Col ' establece la nueva columna

' incrementa el tipo de orden
If i <> m_iSortCol Then
' si hace clic en una columna nueva, inicia con orden ascendente
m_iSortType = 1
Else
' si hace clic en la misma columna, alterna entre orden ascendente y orden descendente
m_iSortType = m_iSortType + 1
If m_iSortType = 3 Then m_iSortType = 1
End If

DoColumnSort

End Sub

Sub DoColumnSort()
'-------------------------------------------------------------------------------------------
' orden de tipo intercambio en la columna m_iSortCol
'-------------------------------------------------------------------------------------------

With MSHFlexGrid1
.Redraw = False
.Row = 1
.RowSel = .Rows - 1
.Col = m_iSortCol
.Sort = m_iSortType
.Redraw = True
End With

End Sub

Private Sub Form_Resize()

Dim sngButtonTop As Single
Dim sngScaleWidth As Single
Dim sngScaleHeight As Single

On Error GoTo Form_Resize_Error
With Me
sngScaleWidth = .ScaleWidth
sngScaleHeight = .ScaleHeight

' mueve el botón Cerrar a la esquina superior derecha
With .cmdClose
sngButtonTop = sngScaleHeight - (.Height + MARGIN_SIZE)
.Move sngScaleWidth - (.Width + MARGIN_SIZE), sngButtonTop
End With

.MSHFlexGrid1.Move MARGIN_SIZE, _
MARGIN_SIZE, _
sngScaleWidth - (2 * MARGIN_SIZE), _
sngButtonTop - (2 * MARGIN_SIZE)

End With
Exit Sub

Form_Resize_Error:
' evita errores en valores negativos
Resume Next

End Sub
Private Sub cmdClose_Click()

Unload Me

End Sub