Help Printing MSGridFlex Control

I have a simple form with a few command button (exit, print, fill grid) which work fine except the print comand. The Fill Grid command populates a flexgrid with say 20 rows and 50 columns with numerical values in the cells. When i run this it works fine in the form.

My problem is trying to print the grid i've tried printing the form with the following code
Private Sub CmdPrint_Click()
End Sub

The result is the form printing out but the grid area is blank...actually black and grey streaks and no cells or values showing up. Also, once this problem is resolved i need to determine how to print the grid when the columns go beyond the width of the control. Another words the horizontal scroll bar is needed to display columns to the left.

I don't need the form printed and would actually like to just print the control vs a form and control taking up the page.

Any help here would be apprciated



  • what you can do is traverse thru the flexgrid control and send each cell's text value to the printer object. you may need to adjust the layout but this will get you started-

    Private Sub DataPrint()
    Printer.TrackDefault = True
    Printer.FontName = "Courier"
    Printer.FontSize = "10"

    Dim myCol As Integer
    Dim myRow As Integer

    With Me.MSFlexGrid1
    For myRow = 1 To .Rows - 1
    For myCol = 1 To .Cols - 1
    .Col = myCol
    .Row = myRow
    If myCol = 1 Then Printer.Print 'NEW LINE
    Printer.Print .Text,
    Next myCol
    Next myRow
    End With

    End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion