Spread Windows Forms 12.0 Product Documentation
UserDefinedFormat Property (DateTimeCellType)

FarPoint.Win.Spread Assembly > FarPoint.Win.Spread.CellType Namespace > DateTimeCellType Class : UserDefinedFormat Property
Gets or sets the format used when the date-time format is user-defined.
Public Property UserDefinedFormat As String
Dim instance As DateTimeCellType
Dim value As String
instance.UserDefinedFormat = value
value = instance.UserDefinedFormat
public string UserDefinedFormat {get; set;}

Property Value

String containing the format specifiers
Specified format is not valid

The formats supported are in the DateTimeFormatInfo object that can be found in the Microsoft .NET framework SDK documentation. Discussion of these formats are in the date-time formats and Custom DateTime Format Strings topics in the Microsoft .NET Developer's Guide. The fractional seconds are not supported in the DateTimeCellType (though they are in the GeneralCellType).

Briefly summarized, you can use any of the following custom date-time format specifiers:

Format Specifier Description
d, dd numeric day
ddd string of abbreviated day
dddd string of full day name
f,ff, ... most significant digits
of the seconds fraction
F,FF, ... most significant digits
of the seconds fraction
without trailing zeros
h, hh hour (1 to 12)
H, HH hour (1 to 24)
m, mm numeric minutes
M, MM numeric month
MMM, MMMM abbreviated, full month name
s, ss numeric seconds
t, tt AM/PM designated
y, yy, yyyy numeric year
z, zz, zzz time zone offset

This example specifies the strings to use for the day names and month names when the format is "dddd MMMM d, yyyy".
FarPoint.Win.Spread.CellType.DateTimeCellType dt = new FarPoint.Win.Spread.CellType.DateTimeCellType();
string[] dNames = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
string[] mNames = {"Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec",""};
string[] sdNames = {"SU", "M", "T", "W", "TH", "F", "S"};
string[] smNames = {"J", "F", "M", "A", "MY", "J", "JY", "AG", "S", "O", "N", "D",""};
string okbutn = "Accept";
string canbutn = "Decline";
dt.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined;
dt.UserDefinedFormat = "dddd  MMMM d,  yyyy";
dt.DayNames = dNames;
dt.MonthNames = mNames;
dt.ShortDayNames = sdNames;
dt.ShortMonthNames = smNames;
dt.SetCalendarText(okbutn, canbutn);
fpSpread1.ActiveSheet.Cells[0, 0].CellType = dt;
fpSpread1.ActiveSheet.Cells[0, 0].Value = System.DateTime.Now;
fpSpread1.ActiveSheet.Columns[0].Width = 130;
Dim dt As New FarPoint.Win.Spread.CellType.DateTimeCellType()
Dim dNames() As String = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
Dim mNames() As String = {"Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec",""}
Dim sdNames() As String = {"SU", "M", "T", "W", "TH", "F", "S"}
Dim smNames() As String = {"J", "F", "M", "A", "MY", "J", "JY", "AG", "S", "O", "N", "D",""}
Dim okbutn As String = "Accept"
Dim canbutn As String = "Decline"
dt.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined
dt.UserDefinedFormat = "dddd  MMMM d,  yyyy"
dt.DayNames = dNames
dt.MonthNames = mNames
dt.ShortDayNames = sdNames
dt.ShortMonthNames = smNames
dt.SetCalendarText(okbutn, canbutn)
fpSpread1.ActiveSheet.Cells(0, 0).CellType = dt
fpSpread1.ActiveSheet.Cells(0, 0).Value = Now
fpSpread1.ActiveSheet.Columns(0).Width = 130
See Also


DateTimeCellType Class
DateTimeCellType Members
DateTimeFormatInfo Object
Date-Time Format Strings