void setPrintableButton_Click(object sender, EventArgs e)
{
Template template = Template.Default;
Section displayHeaderSection = template.ColumnHeaders[0];
ColumnHeaderSection printHeaderSection = new ColumnHeaderSection();
printHeaderSection.Height = 40;
// Initialize and add a PrintInfoCell into printHeaderSection.
PrintInfoCell printInfoCell = new PrintInfoCell();
printInfoCell.FormatString = "{PageNumber} of {PageCount}";
printInfoCell.Size = new Size(template.Width, printHeaderSection.Height);
printHeaderSection.Cells.Add(printInfoCell);
template.ColumnHeaders.Add(printHeaderSection);
// The section only use to display in screen.
displayHeaderSection.Printable = false;
displayHeaderSection.Visible = true;
// The section only use to display when print.
printHeaderSection.Visible = false;
printHeaderSection.Printable = true;
// Reload template
this.gcMultiRow1.Template = template;
this.gcMultiRow1.RowCount = 100;
// Print column header in every page.
this.gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages;
try
{
this.gcMultiRow1.PrintPreview();
}
catch(Exception ex)
{
// Can't find printer.
MessageBox.Show(ex.Message);
}
}
Private Sub setPrintableButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setPrintableButton.Click
Dim template1 As Template = Template.Default
Dim displayHeaderSection As Section = template1.ColumnHeaders(0)
Dim printHeaderSection As New ColumnHeaderSection()
printHeaderSection.Height = 40
' Initialize and add a PrintInfoCell into printHeaderSection.
Dim printInfoCell As New PrintInfoCell()
printInfoCell.FormatString = "{PageNumber} of {PageCount}"
printInfoCell.Size = New Size(template1.Width, printHeaderSection.Height)
printHeaderSection.Cells.Add(printInfoCell)
template1.ColumnHeaders.Add(printHeaderSection)
' The section only use to display in screen.
displayHeaderSection.Printable = False
displayHeaderSection.Visible = True
' The section only use to display when print.
printHeaderSection.Visible = False
printHeaderSection.Printable = True
' Reload template
Me.gcMultiRow1.Template = template1
Me.gcMultiRow1.RowCount = 100
' Print column header in every page.
Me.gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages
Try
Me.gcMultiRow1.PrintPreview()
Catch ex As Exception
' Can't find printer.
MessageBox.Show(ex.Message)
End Try
End Sub