v4.22 and Printing

Jan 25, 2010 at 2:10 PM

Hi all,

I am using VB.net (2005) and SourceGrid v4.22. I have a grid class that inherits from SourceGrid.Grid to encapsulate standard settings that I like to use throughout my project. It works fantastic.

I am trying to implement printing and have it working but there is an issue I am trying to resolve. I implemented the following routine in my custom SourceGrid class:

Public Sub Print(ByVal parentForm As System.Windows.Forms.Form)
    Dim gridDocument As New SourceGrid.Exporter.GridPrintDocument(Me)
    gridDocument.DefaultPageSettings.Landscape = True

    Dim pd As New PrintDialog()
    pd.Document = gridDocument
    pd.PrinterSettings.DefaultPageSettings.Landscape = True
    If pd.ShowDialog(parentForm) = DialogResult.OK Then
        gridDocument.Print()
    End If
 End Sub

It works except that in some columns data is cut off, that is some of the text is displayed then '...' is displayed next to it indicating that there is more data but the column width is too narrow to display it. This is OK if the grid is viewed in the GUI where the column can be resized. Unfortunately this cannot be done on the printed page.

Any ideas or tips on how to get the column to fully display (both the column header and the data) on the printed page?

 

 

Coordinator
Feb 5, 2010 at 7:19 AM

There is a method to calculate the width of a cell with text (sorry i do not know which exactly).

You could either use that method to resize grid, or enhance printing routine so that it would expand cells automatically

Mar 16, 2010 at 3:53 PM
Edited Mar 16, 2010 at 3:53 PM

You can create class that extends SourceGrid.Exporter.GridPrintDocument and override GetColumnWidth method, so you can do your own column width calculations. Current implementation is using onscreen grid width.