GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 : DateTimePickerCell クラス |
DateTimePickerCellクラスは、日時ピッカーコントロール(日付と時刻を編集するフィールド)を表示する特別なタイプのCellです。選択されたDateTimePickerCellはDateTimePickerEditingControlをホストし、ユーザーはその編集コントロールを使用してセルの値を編集できます。
セルの値がnull 参照 (Visual Basicでは Nothing)の場合、セルが編集状態になると、DateTimePickerCellはDateTime.Nowを表示します。
継承時の注意:
DateTimePickerCellから継承した派生クラスに新しいプロパティを追加するときは、必ずCloneメソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスのCloneメソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。
using System; using System.Drawing; using System.Windows.Forms; using System.Data; namespace GrapeCity.Win.MultiRow.SampleCode { public class DateTimePickerCellDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); public DateTimePickerCellDemo() { this.Text = "DateTimePicker Demo"; this.Size = new Size(550, 300); // Add MultiRow to form this.gcMultiRow1.Dock = DockStyle.Fill; this.Controls.Add(this.gcMultiRow1); this.Load += new EventHandler(Form1_Load); } private void Form1_Load(object sender, EventArgs e) { // create a template with 4 DateTimePicker box cell columns. DateTimePickerCell commonDateTimePickerCell = this.CreateCommonDateTimePickerCell(); DateTimePickerCell showTimeDateTimePickerCell = this.CreateShowTimeDateTimePickerCell(); DateTimePickerCell customAppearanceDateTimePickerCell = this.CreateCustomCalendarStyleAndFormat(); DateTimePickerCell hiddenDropDownButtonDateTimePickerCell = this.CreateDateTimePickerCellHiddenDropDownButton(); Cell[] DateTimePickerCells = new Cell[] { commonDateTimePickerCell, showTimeDateTimePickerCell, customAppearanceDateTimePickerCell, hiddenDropDownButtonDateTimePickerCell }; this.gcMultiRow1.Template = Template.CreateGridTemplate(DateTimePickerCells); this.gcMultiRow1.ColumnHeaders[0][0].Value = "Show Date"; this.gcMultiRow1.ColumnHeaders[0][1].Value = "Show Time"; this.gcMultiRow1.ColumnHeaders[0][2].Value = "Custom Appearance"; this.gcMultiRow1.ColumnHeaders[0][3].Value = "Hide Button"; this.gcMultiRow1.RowCount = 6; } DateTimePickerCell CreateCommonDateTimePickerCell() { DateTimePickerCell dateTimePickerCell1 = new DateTimePickerCell(); dateTimePickerCell1.Value = DateTime.Now; dateTimePickerCell1.Format = DateTimePickerFormat.Short; dateTimePickerCell1.Size = new Size(120, 21); return dateTimePickerCell1; } DateTimePickerCell CreateShowTimeDateTimePickerCell() { DateTimePickerCell dateTimePickerCell1 = new DateTimePickerCell(); dateTimePickerCell1.Format = DateTimePickerFormat.Time; dateTimePickerCell1.Value = DateTime.Now; dateTimePickerCell1.Size = new Size(120, 21); dateTimePickerCell1.ShowUpDown = true; return dateTimePickerCell1; } 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; } DateTimePickerCell CreateDateTimePickerCellHiddenDropDownButton() { DateTimePickerCell dateTimePickerCell1 = new DateTimePickerCell(); dateTimePickerCell1.Value = DateTime.Now; dateTimePickerCell1.Size = new Size(120, 21); // Hide drop down button when non edit status. dateTimePickerCell1.ShowDropDownButton = CellButtonVisibility.NotShown; return dateTimePickerCell1; } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new DateTimePickerCellDemo()); } } }
Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Data Imports GrapeCity.Win.MultiRow Public Class DateTimePickerCellDemo Inherits Form Private gcMultiRow1 As New GcMultiRow() Public Sub New() Me.Text = "DateTimePicker Demo" Me.Size = New Size(550, 300) ' Add MultiRow to form Me.gcMultiRow1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcMultiRow1) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load ' create a template with 4 DateTimePicker box cell columns. Dim commonDateTimePickerCell As DateTimePickerCell = Me.CreateCommonDateTimePickerCell() Dim showTimeDateTimePickerCell As DateTimePickerCell = Me.CreateShowTimeDateTimePickerCell() Dim customAppearanceDateTimePickerCell As DateTimePickerCell = Me.CreateCustomCalendarStyleAndFormat() Dim hiddenDropDownButtonDateTimePickerCell As DateTimePickerCell = Me.CreateDateTimePickerCellHiddenDropDownButton() Dim DateTimePickerCells As Cell() = New Cell() {commonDateTimePickerCell, showTimeDateTimePickerCell, customAppearanceDateTimePickerCell, hiddenDropDownButtonDateTimePickerCell} Me.gcMultiRow1.Template = Template.CreateGridTemplate(DateTimePickerCells) Me.gcMultiRow1.ColumnHeaders(0)(0).Value = "Show Date" Me.gcMultiRow1.ColumnHeaders(0)(1).Value = "Show Time" Me.gcMultiRow1.ColumnHeaders(0)(2).Value = "Custom Appearance" Me.gcMultiRow1.ColumnHeaders(0)(3).Value = "Hide Button" Me.gcMultiRow1.RowCount = 6 End Sub Private Function CreateCommonDateTimePickerCell() As DateTimePickerCell Dim dateTimePickerCell1 As New DateTimePickerCell() dateTimePickerCell1.Value = DateTime.Now dateTimePickerCell1.Format = DateTimePickerFormat.Short dateTimePickerCell1.Size = New Size(120, 21) Return dateTimePickerCell1 End Function Private Function CreateShowTimeDateTimePickerCell() As DateTimePickerCell Dim dateTimePickerCell1 As New DateTimePickerCell() dateTimePickerCell1.Format = DateTimePickerFormat.Time dateTimePickerCell1.Value = DateTime.Now dateTimePickerCell1.Size = New Size(120, 21) dateTimePickerCell1.ShowUpDown = True Return dateTimePickerCell1 End Function 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 Private Function CreateDateTimePickerCellHiddenDropDownButton() As DateTimePickerCell Dim dateTimePickerCell1 As New DateTimePickerCell() dateTimePickerCell1.Value = DateTime.Now dateTimePickerCell1.Size = New Size(120, 21) ' Hide drop down button when non edit status. dateTimePickerCell1.ShowDropDownButton = CellButtonVisibility.NotShown Return dateTimePickerCell1 End Function <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New DateTimePickerCellDemo()) End Sub End Class
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.MultiRow.Cell
GrapeCity.Win.MultiRow.DateTimePickerCell