In this tutorial, you will learn how to use the printing and exporting capabilities of True DBGrid for WinForms.
Complete the following steps:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' Change the presentation of the grid. With Me.C1TrueDBGrid1.Splits(0).DisplayColumns .Item("Country").Style.BackColor = System.Drawing.Color.Cyan Dim fntFont As Font fntFont = New Font("Times New Roman", .Item("Country").Style.Font.Size, FontStyle.Regular) .Item("Country").Style.Font = fntFont .Item("Last").Style.ForeColor = System.Drawing.Color.Red End With Me.C1TrueDBGrid1.Columns("last").NumberFormat = "FormatText Event" With Me.C1TrueDBGrid1.HeadingStyle Dim fntfont As Font fntfont = New Font(.Font.Name, .Font.Size, FontStyle.Bold) .Font = fntfont .BackColor = System.Drawing.Color.Blue .ForeColor = System.Drawing.Color.Yellow End With |
To write code in C#
C# |
Copy Code
|
---|---|
// Change the presentation of the grid. C1DisplayColumn col = this.c1TrueDBGrid1.Splits[0].DisplayColumns["Country"]; col.Style.BackColor = System.Drawing.Color.Cyan; Font fntFont; fntFont = new Font("Times new Roman", col.Style.Font.Size, FontStyle.Regular); col.Style.Font = fntFont; c1TrueDBGrid1.Splits[0].DisplayColumns["Last"].Style.ForeColor = System.Drawing.Color.Red; this.c1TrueDBGrid1.Columns["last"].NumberFormat = "FormatText event"; Font fntfont; fntfont = new Font(Font.Name, this.c1TrueDBGrid1.HeadingStyle.Font.Size, FontStyle.Bold); this.c1TrueDBGrid1.HeadingStyle.Font = fntfont; this.c1TrueDBGrid1.HeadingStyle.BackColor = System.Drawing.Color.Blue; this.c1TrueDBGrid1.HeadingStyle.ForeColor = System.Drawing.Color.Yellow; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub C1TrueDBGrid1_FormatText(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.FormatTextEventArgs) Handles C1TrueDBGrid1.FormatText e.Value = UCase(e.Value) End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void C1TrueDBGrid1_FormatText(object sender, C1.Win.C1TrueDBGrid.FormatTextEventArgs e) { e.Value = e.Value.ToUpper(); } |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
With Me.C1TrueDBGrid1.PrintInfo Dim fntFont As Font fntFont = New Font(.PageHeaderStyle.Font.Name, .PageHeaderStyle.Font.Size, FontStyle.Italic) .PageHeaderStyle.Font = fntFont .PageHeader = "Composers Table" ' Column headers will be on every page. .RepeatColumnHeaders = True ' Display page numbers (centered). .PageFooter = "Page: \p" ' Invoke print preview. .UseGridColors = True .PrintPreview() End With |
To write code in C#
C# |
Copy Code
|
---|---|
Font fntFont; fntFont = new Font(this.c1TrueDBGrid1.PrintInfo.PageHeaderStyle.Font.Name, this.c1TrueDBGrid1.PrintInfo.PageHeaderStyle.Font.Size, FontStyle.Italic); this.c1TrueDBGrid1.PrintInfo.PageHeaderStyle.Font = fntFont; this.c1TrueDBGrid1.PrintInfo.PageHeader = "Composers Table"; // Column headers will be on every page. this.c1TrueDBGrid1.PrintInfo.RepeatColumnHeaders = true; // Display page numbers (centered). this.c1TrueDBGrid1.PrintInfo.PageFooter = "Page: \\p"; // Invoke print preview. this.c1TrueDBGrid1.PrintInfo.UseGridColors = true; this.c1TrueDBGrid1.PrintInfo.PrintPreview(); |
You've successfully completed using PrintInfo and Print Preview; this concludes tutorial 15.