GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow.InputMan 名前空間 : GcTimeSpanCell クラス |
Public Class GcTimeSpanCell Inherits FieldsEditorCell
public class GcTimeSpanCell : FieldsEditorCell
GcTimeSpanCellを使用すると、機能的なタイムスパン(期間や時間の長さ)入力インタフェースを迅速かつ効率的に設計できます。
GcTimeSpanCellを使用する場合、タイムスパン値のデータ検証の必要性が制限されます。
using System; using System.Windows.Forms; using System.Drawing; namespace GrapeCity.Win.MultiRow.InputMan.SampleCode { class GcTimeSpanCellDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); private Label label = new Label(); public GcTimeSpanCellDemo() { this.Text = "GcTimeSpanCell Demo"; this.Size = new Size(350, 300); // Add MultiRow to form this.gcMultiRow1.Dock = DockStyle.Fill; this.Controls.Add(this.gcMultiRow1); this.label.Dock = DockStyle.Bottom; this.label.Height = 50; this.label.BackColor = SystemColors.Info; this.label.Text = " Enter edit mode, hit CTR+0 to set value to 0, and click the SpinButton to modify the each field value, you use the Alt+Substract to switch the sign, exits the edit mode, only the hh:mm:ss will display."; this.Controls.Add(label); this.Load += new EventHandler(Form1_Load); this.StartPosition = FormStartPosition.CenterScreen; } private void Form1_Load(object sender, EventArgs e) { GcTimeSpanCell gcTimeSpanCell1 = new GcTimeSpanCell(); SetGcTimeSpanCellFields(gcTimeSpanCell1); SetGcTimeSpanCellDisplayFields(gcTimeSpanCell1); SetShortcutsAndSideButtons(gcTimeSpanCell1); Template template1 = Template.CreateGridTemplate(new Cell[] { gcTimeSpanCell1, gcTimeSpanCell1.Clone() as Cell }, 200, AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber); gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 3; } private void SetGcTimeSpanCellFields(GcTimeSpanCell gcTimeSpanCell1) { gcTimeSpanCell1.Fields.Clear(); TimeSpanSignField fields0 = new TimeSpanSignField(); TimeSpanDayField fields1 = new TimeSpanDayField(); fields1.Digits = 1; TimeSpanLiteralField fields2 = new TimeSpanLiteralField(); fields2.Text = "."; TimeSpanHourField fields3 = new TimeSpanHourField(); fields3.Digits = 2; TimeSpanLiteralField fields4 = new TimeSpanLiteralField(); fields4.Text = ":"; TimeSpanMinuteField fields5 = new TimeSpanMinuteField(); fields5.Digits = 2; TimeSpanLiteralField fields6 = new TimeSpanLiteralField(); fields6.Text = ":"; TimeSpanSecondField fields7 = new TimeSpanSecondField(); fields7.Digits = 2; gcTimeSpanCell1.Fields.AddRange(new TimeSpanField[] { fields0, fields1, fields2, fields3, fields4, fields5, fields6, fields7 }); } private void SetGcTimeSpanCellDisplayFields(GcTimeSpanCell gcTimeSpanCell1) { gcTimeSpanCell1.DisplayFields.Clear(); TimeSpanSignDisplayField timeSpanSignDisplayField1 = new TimeSpanSignDisplayField(); TimeSpanHourDisplayField timeSpanHourDisplayField1 = new TimeSpanHourDisplayField(); TimeSpanLiteralDisplayField timeSpanLiteralDisplayField1 = new TimeSpanLiteralDisplayField(); TimeSpanMinuteDisplayField timeSpanMinuteDisplayField1 = new TimeSpanMinuteDisplayField(); TimeSpanLiteralDisplayField timeSpanLiteralDisplayField2 = new TimeSpanLiteralDisplayField(); TimeSpanSecondDisplayField timeSpanSecondDisplayField1 = new TimeSpanSecondDisplayField(); timeSpanHourDisplayField1.Digits = 2; timeSpanLiteralDisplayField1.Text = ":"; timeSpanMinuteDisplayField1.Digits = 2; timeSpanLiteralDisplayField2.Text = ":"; timeSpanSecondDisplayField1.Digits = 2; gcTimeSpanCell1.DisplayFields.AddRange(new TimeSpanDisplayField[] { timeSpanSignDisplayField1, timeSpanHourDisplayField1, timeSpanLiteralDisplayField1, timeSpanMinuteDisplayField1, timeSpanLiteralDisplayField2, timeSpanSecondDisplayField1 }); } private void SetShortcutsAndSideButtons(GcTimeSpanCell gcTimeSpanCell1) { //In edit mode, hit the CTR+0 to set value to 0. gcTimeSpanCell1.ShortcutKeys.Add(Keys.Control | Keys.D0, "SetZero"); gcTimeSpanCell1.ShortcutKeys.Add(Keys.Control | Keys.NumPad0, "SetZero"); //In edit mode, hit the Alt+Subtract to switch the sign. gcTimeSpanCell1.ShortcutKeys.Add(Keys.Alt | Keys.Subtract, "SwitchSign"); gcTimeSpanCell1.ShortcutKeys.Add(Keys.Alt | Keys.OemMinus, "SwitchSign"); gcTimeSpanCell1.SideButtons.Clear(); gcTimeSpanCell1.SideButtons.Add(new SpinButton()); } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new GcTimeSpanCellDemo()); } } }
Imports System Imports System.Windows.Forms Imports System.Drawing Namespace GrapeCity.Win.MultiRow.InputMan.SampleCode Class GcTimeSpanCellDemo Inherits Form Private gcMultiRow1 As New GcMultiRow() Private label As New Label() Public Sub New() Me.Text = "GcTimeSpanCell Demo" Me.Size = New Size(350, 300) ' Add MultiRow to form Me.gcMultiRow1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcMultiRow1) Me.label.Dock = DockStyle.Bottom Me.label.Height = 50 Me.label.BackColor = SystemColors.Info Me.label.Text = " Enter edit mode, hit CTR+0 to set value to 0, and click the SpinButton to modify the each field value, you use the Alt+Substract to switch the sign, exits the edit mode, only the hh:mm:ss will display." Me.Controls.Add(label) Me.StartPosition = FormStartPosition.CenterScreen End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim gcTimeSpanCell1 As New GcTimeSpanCell() SetGcTimeSpanCellFields(gcTimeSpanCell1) SetGcTimeSpanCellDisplayFields(gcTimeSpanCell1) SetShortcutsAndSideButtons(gcTimeSpanCell1) Dim template1 As Template = Template.CreateGridTemplate(New Cell() {gcTimeSpanCell1, TryCast(gcTimeSpanCell1.Clone(), Cell)}, 200, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber) gcMultiRow1.Template = template1 gcMultiRow1.RowCount = 3 End Sub Private Sub SetGcTimeSpanCellFields(ByVal gcTimeSpanCell1 As GcTimeSpanCell) gcTimeSpanCell1.Fields.Clear() Dim fields0 As New TimeSpanSignField() Dim fields1 As New TimeSpanDayField() fields1.Digits = 1 Dim fields2 As New TimeSpanLiteralField() fields2.Text = "." Dim fields3 As New TimeSpanHourField() fields3.Digits = 2 Dim fields4 As New TimeSpanLiteralField() fields4.Text = ":" Dim fields5 As New TimeSpanMinuteField() fields5.Digits = 2 Dim fields6 As New TimeSpanLiteralField() fields6.Text = ":" Dim fields7 As New TimeSpanSecondField() fields7.Digits = 2 gcTimeSpanCell1.Fields.AddRange(New TimeSpanField() {fields0, fields1, fields2, fields3, fields4, fields5, _ fields6, fields7}) End Sub Private Sub SetGcTimeSpanCellDisplayFields(ByVal gcTimeSpanCell1 As GcTimeSpanCell) gcTimeSpanCell1.DisplayFields.Clear() Dim timeSpanSignDisplayField1 As New TimeSpanSignDisplayField() Dim timeSpanHourDisplayField1 As New TimeSpanHourDisplayField() Dim timeSpanLiteralDisplayField1 As New TimeSpanLiteralDisplayField() Dim timeSpanMinuteDisplayField1 As New TimeSpanMinuteDisplayField() Dim timeSpanLiteralDisplayField2 As New TimeSpanLiteralDisplayField() Dim timeSpanSecondDisplayField1 As New TimeSpanSecondDisplayField() timeSpanHourDisplayField1.Digits = 2 timeSpanLiteralDisplayField1.Text = ":" timeSpanMinuteDisplayField1.Digits = 2 timeSpanLiteralDisplayField2.Text = ":" timeSpanSecondDisplayField1.Digits = 2 gcTimeSpanCell1.DisplayFields.AddRange(New TimeSpanDisplayField() {timeSpanSignDisplayField1, timeSpanHourDisplayField1, timeSpanLiteralDisplayField1, timeSpanMinuteDisplayField1, timeSpanLiteralDisplayField2, timeSpanSecondDisplayField1}) End Sub Private Sub SetShortcutsAndSideButtons(ByVal gcTimeSpanCell1 As GcTimeSpanCell) 'In edit mode, hit the CTR+0 to set value to 0. gcTimeSpanCell1.ShortcutKeys.Add(Keys.Control Or Keys.D0, "SetZero") gcTimeSpanCell1.ShortcutKeys.Add(Keys.Control Or Keys.NumPad0, "SetZero") 'In edit mode, hit the Alt+Subtract to switch the sign. gcTimeSpanCell1.ShortcutKeys.Add(Keys.Alt Or Keys.Subtract, "SwitchSign") gcTimeSpanCell1.ShortcutKeys.Add(Keys.Alt Or Keys.OemMinus, "SwitchSign") gcTimeSpanCell1.SideButtons.Clear() gcTimeSpanCell1.SideButtons.Add(New SpinButton()) End Sub <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New GcTimeSpanCellDemo()) End Sub End Class End Namespace
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.MultiRow.Cell
GrapeCity.Win.MultiRow.InputMan.InputManCellBase
GrapeCity.Win.MultiRow.InputMan.FieldsEditorCell
GrapeCity.Win.MultiRow.InputMan.GcTimeSpanCell