Spread for ASP.NET 9.0 Product Documentation
FormatString Property (DateTimeCellType)
Example 


Gets or sets the format for dates.
Syntax
'Declaration
 
Public Overrides Property FormatString As String
'Usage
 
Dim instance As DateTimeCellType
Dim value As String
 
instance.FormatString = value
 
value = instance.FormatString
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.
FarPoint.Web.Spread.DateTimeCellTypedatecell=new FarPoint.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;
Dim datecell As New FarPoint.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 7, Windows 8, Windows 10, Windows Vista, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows XP Professional

See Also

Reference

DateTimeCellType Class
DateTimeCellType Members

 

 


Copyright © GrapeCity, inc. All rights reserved.