GrapeCity MultiRow Windows Forms Documentation
Format Property (DateTimePickerCell)
Example 


Gets or sets the format of the date and time displayed in the DateTimePickerCell.
Syntax
<SRCategoryAttribute("Appearance")>
<SRDescriptionAttribute("Indicates whether dates and times are displayed using standard or custom formatting.")>
<DefaultValueAttribute()>
Public Property Format As DateTimePickerFormat
Dim instance As DateTimePickerCell
Dim value As DateTimePickerFormat
 
instance.Format = value
 
value = instance.Format
[SRCategory("Appearance")]
[SRDescription("Indicates whether dates and times are displayed using standard or custom formatting.")]
[DefaultValue()]
public DateTimePickerFormat Format {get; set;}

Property Value

One of the System.Windows.Forms.DateTimePickerFormat values. The default is System.Windows.Forms.DateTimePickerFormat.Long.
Exceptions
ExceptionDescription
System.ComponentModel.InvalidEnumArgumentExceptionThe specified value is not one of the System.Windows.Forms.DateTimePickerFormat values.
Remarks
This property determines the date and time format the date is displayed in. The date and time format is based on the user's regional settings in their operating system.
Note
The Format property must be set to System.Windows.Forms.DateTimePickerFormat.Custom for the CustomFormat property to affect the formatting of the displayed date and time.
To display only time in a DateTimePickerCell, set the Format to System.Windows.Forms.DateTimePickerFormat.Time, and the ShowUpDown property to true.
Example
The following code example shows how to customize a date time picker cell's behavior or appearance. This code example is part of a larger example provided for the DateTimePickerCell class.
DateTimePickerCell CreateCustomCalendarStyleAndFormat()
        {
            DateTimePickerCell dateTimePickerCell1 = new DateTimePickerCell();

            dateTimePickerCell1.Value = DateTime.Now;

            dateTimePickerCell1.Size = new Size(120, 21);

            dateTimePickerCell1.CustomFormat = "yyyy/MM";

            dateTimePickerCell1.Format = DateTimePickerFormat.Custom;

            dateTimePickerCell1.CalendarFont = new Font(Control.DefaultFont, FontStyle.Bold);

            dateTimePickerCell1.CalendarForeColor = Color.Red;

            dateTimePickerCell1.CalendarMonthBackground = Color.Blue;

            dateTimePickerCell1.CalendarTitleBackColor = Color.Black;

            dateTimePickerCell1.CalendarTitleForeColor = Color.White;

            dateTimePickerCell1.CalendarTrailingForeColor = Color.Yellow;

            dateTimePickerCell1.DropDownAlign = LeftRightAlignment.Right;

            return dateTimePickerCell1;
        }
Private Function CreateCustomCalendarStyleAndFormat() As DateTimePickerCell
        Dim dateTimePickerCell1 As New DateTimePickerCell()

        dateTimePickerCell1.Value = DateTime.Now

        dateTimePickerCell1.Size = New Size(120, 21)

        dateTimePickerCell1.CustomFormat = "yyyy/MM"

        dateTimePickerCell1.Format = DateTimePickerFormat.Custom

        dateTimePickerCell1.CalendarFont = New Font(Control.DefaultFont, FontStyle.Bold)

        dateTimePickerCell1.CalendarForeColor = Color.Red

        dateTimePickerCell1.CalendarMonthBackground = Color.Blue

        dateTimePickerCell1.CalendarTitleBackColor = Color.Black

        dateTimePickerCell1.CalendarTitleForeColor = Color.White

        dateTimePickerCell1.CalendarTrailingForeColor = Color.Yellow

        dateTimePickerCell1.DropDownAlign = LeftRightAlignment.Right

        Return dateTimePickerCell1
    End Function
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

DateTimePickerCell Class
DateTimePickerCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.