• Domingo 5 de Mayo de 2024, 03:41

Autor Tema:  Re: imprimir MSFlexGrid  (Leído 3211 veces)

CarolinaP

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Re: imprimir MSFlexGrid
« en: Martes 10 de Septiembre de 2002, 04:39 »
0
Hola a todos!

Como veran, estoy un poco complicada con el MSFlexGrid, pero bueno...

Lo que quisiera saber es si alguien me puede ayudar a adivinar como imprimir los datos de un MSF. En realidad puedo imprimir pero la impresion es un poco "desprolija", es decir, imprime tipo reporte y no tipo tabla. No queda muy lindo...

Si alguien me pudiera dar una mano, lo agradeceria...

Salu2,
Carolina!

nop_will

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
    • http://www.esferas.8m.com
imprimir MSFlexGrid
« Respuesta #1 en: Martes 5 de Noviembre de 2002, 05:38 »
0
Te envio el código para imprimir el grid espero que te sirva, porque hoy me entere de está página así que de inmediato te mando esto, espero que te sirva:

 Pasos a seguir para imprimir un grid
 -------------------------------------
 1. Crear un grid y meterlo en el Form1, metiendole (por ejemplo) 6 filas  y columnas.
 
 2. Añadir el siguinete código al evento Form1 Click:
 
    Sub Form_Click ()
       Dim i, j
       For i = 0 To Grid1.Cols - 1
          For j = 0 To Grid1.Rows - 1
             Grid1.Col = i
             Grid1.Row = j
             Grid1.Text = Format$(i + j + i ^ j)
          Next
       Next
       Call Grid_Print(Grid1)
       Printer.EndDoc
    End Sub
 
 2. Añadir el siguiente código a la sección de declaraciones globales:
 
    Sub Grid_Print (grid As Control)
       Dim tppx As Integer
       Dim tppy As Integer
       tppx = Printer.TwipsPerPixelX
       tppy = Printer.TwipsPerPixelY
       Dim Col As Integer
       Dim Row As Integer
       Dim x0 As Single
       Dim y0 As Single
       Dim x1 As Single
       Dim y1  As Single
       Dim x2  As Single
       Dim y2  As Single
 
       x0 = Printer.CurrentX
       y0 = Printer.CurrentY
 
       If grid.BorderStyle <> 0 Then
          Printer.Line -Step(grid.Width - tppx, grid.Height - tppy), , B
          x0 = x0 + tppx
          y0 = y0 + tppy
       End If
       x1 = x0
       For Col = 0 To grid.Cols - 1
          If Col >= grid.FixedCols And Col < grid.LeftCol Then
             Col = grid.LeftCol
          End If
          If x1 + grid.ColWidth(Col) >= grid.Width Then Exit For
          y1 = y0
          For Row = 0 To grid.Rows - 1
             If Row >= grid.FixedRows And Row < grid.TopRow Then
                Row = grid.TopRow
            End If
             If y1 + grid.RowHeight(Row) >= grid.Height Then Exit For
             Printer.CurrentX = x1 + tppx * 2
             Printer.CurrentY = y1 + tppy
             grid.Col = Col
             grid.Row = Row
             Printer.Print grid.Text
             y1 = y1 + grid.RowHeight(Row)
             If grid.GridLines Then
                y1 = y1 + tppy
             End If
          Next
          x1 = x1 + grid.ColWidth(Col)
          If grid.GridLines Then
             x1 = x1 + tppx
          End If
       Next
       If grid.GridLines Then
          x2 = x0
          y2 = y0
          For Col = 0 To grid.Cols - 1
             If Col >= grid.FixedCols And Col < grid.LeftCol Then
                Col = grid.LeftCol
             End If
             x2 = x2 + grid.ColWidth(Col)
             If x2 >= grid.Width Then Exit For
             Printer.Line (x2, y0)-Step(0, y1 - tppy)
             x2 = x2 + tppx
          Next
          For Row = 0 To grid.Rows - 1
             If Row >= grid.FixedRows And Row < grid.TopRow Then
                Row = grid.TopRow
             End If
             y2 = y2 + grid.RowHeight(Row)
             If y2 >= grid.Height Then Exit For
             Printer.Line (x0, y2)-Step(x1 - tppx, 0)
             y2 = y2 + tppy
          Next
       End If
    End Sub
 
3. Ejecutarlo;)