GrapeCity MultiRow Windows Forms Documentation
FormatString Property
Example 


Gets or sets a value that indicates what format or printing information is displayed.
Syntax
<SRCategoryAttribute("Appearance")>
<EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.FormatStringEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<LocalizableAttribute(True)>
<SRDescriptionAttribute("Indicates what format or printing information is displayed.")>
Public Property FormatString As String
Dim instance As PrintInfoCell
Dim value As String
 
instance.FormatString = value
 
value = instance.FormatString
[SRCategory("Appearance")]
[Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.FormatStringEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[Localizable(true)]
[SRDescription("Indicates what format or printing information is displayed.")]
public string FormatString {get; set;}

Property Value

A System.String value that represents what format or printing information is displayed. The default is String.Empty.
Remarks
You can specify what information is printed in each page. FormatString supports three key words,"PageNumber", "PageCount", and "DateTime". You can combine them with other strings to generate the display string, but the keyword's combination should be enclosed in curly brackets "{}". For example, set this property to "{PageNumber/PageCount}". When printing, if this PrintInfoCell is in the first page, and the page count is 2, "1/2" is shown in this cell. Set this property to {DateTime:yyyy/MM/dd}, when printing, and if today is "2010/1/1", the cell displays "2010/01/01". You can set the CellStyle.FormatProvider to customize the format.
Example
The following code example shows how to use the PrintInfoCell to display the print information when printing. This example is part of a larger example available for the GcMultiRow.PrintSettings.
void AddPrintInfoCellColumnFooterSection(Template template, int height)
        {
            ColumnFooterSection columnFooterSection1 = new ColumnFooterSection();
            columnFooterSection1.Height = height;

            PrintInfoCell printInfoCell1 = new PrintInfoCell();
            printInfoCell1.Size = new Size(500, height);
            printInfoCell1.Location = new Point(template.Width - 500, 0);
            printInfoCell1.Style.Border = Border.Empty;
            printInfoCell1.Style.TextAlign = MultiRowContentAlignment.MiddleRight;

            CultureInfo provider = new CultureInfo("ja-JP",true);
            provider.DateTimeFormat.Calendar = new JapaneseCalendar();
            printInfoCell1.Style.FormatProvider = provider;
            //Indicate the page number and DateTime.
            printInfoCell1.FormatString = "{PageNumber:}/{PageCount:} {DateTime:yyyy年MM月dd日}";
            //You can add other information when printing, such as UserName, CompanyName and so on.
            //printInfoCell1.FormatString = String.Format("{{DateTime:yyyy年MM月dd日}} {0} {1} ",new object[] { Environment.UserName, Application.CompanyName });

            columnFooterSection1.Cells.Add(printInfoCell1);
            template.ColumnFooters.Add(columnFooterSection1);
        }
Private Sub AddPrintInfoCellColumnFooterSection(ByVal template As Template, ByVal height As Integer)
        Dim columnFooterSection1 As New ColumnFooterSection()
        columnFooterSection1.Height = height

        Dim printInfoCell1 As New PrintInfoCell()
        printInfoCell1.Size = New Size(500, height)
        printInfoCell1.Location = New Point(template.Width - 500, 0)
        printInfoCell1.Style.Border = Border.Empty
        printInfoCell1.Style.TextAlign = MultiRowContentAlignment.MiddleRight

        Dim provider As New CultureInfo("ja-JP", True)
        provider.DateTimeFormat.Calendar = New JapaneseCalendar()
        printInfoCell1.Style.FormatProvider = provider
        'Indicate the page number and DateTime.
        printInfoCell1.FormatString = "{PageNumber:}/{PageCount:} {DateTime:yyyy年MM月dd日}"
        'You can add other information when printing, such as UserName, CompanyName and so on.
        'printInfoCell1.FormatString = String.Format("{{DateTime:yyyy年MM月dd日}} {0} {1} ",new object[] { Environment.UserName, Application.CompanyName });

        columnFooterSection1.Cells.Add(printInfoCell1)
        template.ColumnFooters.Add(columnFooterSection1)
    End Sub
Requirements

Target Platforms: 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

Reference

PrintInfoCell Class
PrintInfoCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.