Version

MarginTop Property

Returns the PrintDocument's Margin Top value (read-only). You can set the margins in the UltraGrid.InitializePrint and UltraGrid.InitializePrintPreview events.
Syntax
'Declaration
 
Public ReadOnly Property MarginTop As Integer
public int MarginTop {get;}
Remarks

This property is read-only. You can set the margins in the UltraGrid.InitializePrint and UltraGrid.InitializePrintPreview events using the associated event arg's PrintDocument's DefaultPageSetting's Margins property. Note that this means that margins can not be changed on a par page basis.

Example
InitializeLogicalPrintPage is fired for each page that's being printed or previewed. Following code shows some of the information available in the event.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_InitializeLogicalPrintPage(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableLogicalPrintPageEventArgs) Handles ultraGrid1.InitializeLogicalPrintPage

       Debug.WriteLine("e.Collate = " & e.Collate.ToString())
       Debug.WriteLine("e.Copies = " & e.Copies.ToString())
       Debug.WriteLine("e.DocumentName = " & e.DocumentName)
       Debug.WriteLine("e.Landscape = " & e.Landscape)
       Debug.WriteLine("e.LogicalPageNumber = " & e.LogicalPageNumber)
       Debug.WriteLine("e.DocumentName = " & e.MarginBottom)
       Debug.WriteLine("e.DocumentName = " & e.MarginLeft)
       Debug.WriteLine("e.DocumentName = " & e.MarginRight)
       Debug.WriteLine("e.DocumentName = " & e.MarginTop)
       Debug.WriteLine("e.DocumentName = " & e.PaperHeight)
       Debug.WriteLine("e.DocumentName = " & e.PaperWidth)
       Debug.WriteLine("e.DocumentName = " & e.PrintColors)
       Debug.WriteLine("e.DocumentName = " & e.PrinterName)
       Debug.WriteLine("e.DocumentName = " & e.PrintRange)
       Debug.WriteLine("e.DocumentName = " & e.DocumentName)

       ' You can also setup the footer and header on a per page basis.
       e.LogicalPageLayoutInfo.PageHeader = "Page Title"
       e.LogicalPageLayoutInfo.PageHeaderAppearance.ForeColor = Color.DarkGray

       e.LogicalPageLayoutInfo.PageFooter = "Page Footer Text"
       e.LogicalPageLayoutInfo.PageFooterAppearance.TextHAlign = HAlign.Center

       ' Following code cancels the event to prevent prevewing or printing more than 10 pages.
       If e.LogicalPageNumber > 10 Then
           e.Cancel = True
       End If

   End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_InitializeLogicalPrintPage(object sender, Infragistics.Win.UltraWinGrid.CancelableLogicalPrintPageEventArgs e)
{

	Debug.WriteLine( "e.Collate = " + e.Collate.ToString( ) );
	Debug.WriteLine( "e.Copies = " + e.Copies.ToString( ) );
	Debug.WriteLine( "e.DocumentName = " + e.DocumentName  );
	Debug.WriteLine( "e.Landscape = " + e.Landscape );
	Debug.WriteLine( "e.LogicalPageNumber = " + e.LogicalPageNumber );
	Debug.WriteLine( "e.DocumentName = " + e.MarginBottom );
	Debug.WriteLine( "e.DocumentName = " + e.MarginLeft );
	Debug.WriteLine( "e.DocumentName = " + e.MarginRight );
	Debug.WriteLine( "e.DocumentName = " + e.MarginTop );
	Debug.WriteLine( "e.DocumentName = " + e.PaperHeight );
	Debug.WriteLine( "e.DocumentName = " + e.PaperWidth );
	Debug.WriteLine( "e.DocumentName = " + e.PrintColors );
	Debug.WriteLine( "e.DocumentName = " + e.PrinterName );
	Debug.WriteLine( "e.DocumentName = " + e.PrintRange );
	Debug.WriteLine( "e.DocumentName = " + e.DocumentName  );

	// You can also setup the footer and header on a per page basis.
	e.LogicalPageLayoutInfo.PageHeader = "Page Title";
	e.LogicalPageLayoutInfo.PageHeaderAppearance.ForeColor = Color.DarkGray;
			
	e.LogicalPageLayoutInfo.PageFooter = "Page Footer Text";
	e.LogicalPageLayoutInfo.PageFooterAppearance.TextHAlign = HAlign.Center;

      // Following code cancels the event to prevent prevewing or printing more than 10 pages.
	if ( e.LogicalPageNumber > 10 )
		e.Cancel = true;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also