Spread ASP.NET 6.0 Product Documentation
FormatString Property
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > DateTimeCellType Class : FormatString Property


Glossary Item Box

Gets or sets the format for dates.

Syntax

Visual Basic (Declaration) 
Public Overrides Property FormatString As String
Visual Basic (Usage)Copy Code
Dim instance As DateTimeCellType
Dim value As String
 
instance.FormatString = value
 
value = instance.FormatString
C# 
public override string FormatString {get; set;}

Property Value

String containing the format

Remarks

Specify the format as a string using any of the valid format characters, some of which are listed here:

Format Specifier Description Example (all en-US culture)
d Short date format 1/29/2002
D Long date pattern Tuesday, January 29, 2002
f Full date and time pattern (short time) Tuesday, January 29, 2002 4:27 PM
F Full date and time pattern (long time) Tuesday, January 29, 2002 4:27:42 PM
g General date and time pattern (short time) 1/29/2002 4:27 PM
G General date and time pattern (long time) 1/29/2002 4:27:42 PM
m Month day pattern January 29
r Internet protocol RFC1123 pattern Tue, 29 Jan 2002 16:27:42 GMT
s Sortable date and time pattern 2002-01-29T16:27:42
u Universal sortable date and time pattern 2002-01-29 16:27:42Z
U Universal sortable date and time pattern Tuesday, January 29, 2002 9:27:42 PM
y Year month pattern January, 2002

You can also specify custom date formats. For a complete list of format characters and more information on creating custom date formats, see Date and Time Format Strings in the Microsoft .NET Framework Developers Guide.

Example

The following example creates a date-time cell with a message to display for invalid data and a custom date format. The date format displays the weekday, a comma, and then the month and day for the specified date. The column width is set to display all the text.
C#Copy Code
FarPoint.Web.Spread.DateTimeCellTypedatecell=newFarPoint.Web.Spread.DateTimeCellType();
datecell.ErrorMessage="Needadate!!!";
datecell.FormatString="d";
FpSpread1.Sheets[0].Cells[0,0].CellType=datecell;
FpSpread1.Sheets[0].Cells[0,0].Value=System.DateTime.Now.ToOADate();
FpSpread1.Sheets[0].Columns[0].Width=175;
Visual BasicCopy Code
DimdatecellAsNewFarPoint.Web.Spread.DateTimeCellType()
datecell.ErrorMessage="Needadate!!!"
datecell.FormatString="d"
FpSpread1.Sheets(0).Cells(0,0).CellType=datecell
FpSpread1.Sheets(0).Cells(0,0).Value=System.DateTime.Now.ToOADate()
FpSpread1.Sheets(0).Columns(0).Width=175

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.