GrapeCity.Win.CalendarGrid.v20 アセンブリ > GrapeCity.Win.CalendarGrid 名前空間 : CalendarCheckBoxCellType クラス |
Public Class CalendarCheckBoxCellType Inherits CalendarButtonCellTypeBase
public class CalendarCheckBoxCellType : CalendarButtonCellTypeBase
CalendarCheckBoxCellType クラスは、チェックボックスコントロールを表示する特別なタイプの CalendarCellType です。このセルの値を編集するには、CheckBoxCell が現在のセルのときにクリックするか、スペースキーを押します。
継承時の注意:
CalendarCheckBoxCellType から継承した派生クラスに新しいプロパティを追加するときは、必ず Clone メソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスの Clone メソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。
using System; using System.Windows.Forms; using System.Drawing; using GrapeCity.Win.CalendarGrid; namespace CalendarGridSampleCode { public class CheckBoxCellDemo : Form { private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid(); private Label label = new Label(); public CheckBoxCellDemo() { this.gcCalendarGrid1.Dock = DockStyle.Fill; this.Controls.Add(this.gcCalendarGrid1); this.Load += Form1_Load; this.gcCalendarGrid1.CellValueChanged += gcCalendarGrid1_CellValueChanged; this.label.Dock = DockStyle.Bottom; this.label.Height = 30; this.label.BackColor = SystemColors.Info; this.label.Text = "Click one CheckBoxCell to change the check state, then press ENTER key to commit value."; this.Controls.Add(label); this.Text = "CheckBoxCell Demo"; } private void Form1_Load(object sender, EventArgs e) { CalendarCheckBoxCellType checkBoxCell1 = new CalendarCheckBoxCellType(); checkBoxCell1.ThreeState = true; checkBoxCell1.TrueValue = "Yes"; checkBoxCell1.FalseValue = "No"; checkBoxCell1.IndeterminateValue = "Ignore"; checkBoxCell1.Text = "State"; checkBoxCell1.CheckAlign = ContentAlignment.MiddleRight; CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate(); template1.Content[1, 0].CellType = checkBoxCell1; template1.Content[2, 0].CellType = checkBoxCell1.Clone(); gcCalendarGrid1.Template = template1; } void gcCalendarGrid1_CellValueChanged(object sender, CalendarCellEventArgs e) { //When the value commit, the actual stored value is TrueValue, FalseValue or IndeterminateValue. object currentCellValue = this.gcCalendarGrid1[gcCalendarGrid1.CurrentCellPosition.Date][gcCalendarGrid1.CurrentCellPosition.RowIndex, gcCalendarGrid1.CurrentCellPosition.ColumnIndex].Value; if (currentCellValue != null) { this.label.Text = "The current parsed value is " + currentCellValue.ToString(); } } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new CheckBoxCellDemo()); } } }
Imports System.Windows.Forms Imports System.Drawing Imports GrapeCity.Win.CalendarGrid Namespace CalendarGridSampleCode Public Class CheckBoxCellDemo Inherits Form Private gcCalendarGrid1 As New GcCalendarGrid() Private label As New Label() Public Sub New() Me.gcCalendarGrid1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcCalendarGrid1) AddHandler Me.Load, AddressOf Form1_Load AddHandler Me.gcCalendarGrid1.CellValueChanged, AddressOf gcCalendarGrid1_CellValueChanged Me.label.Dock = DockStyle.Bottom Me.label.Height = 30 Me.label.BackColor = SystemColors.Info Me.label.Text = "Click one CheckBoxCell to change the check state, then press ENTER key to commit value." Me.Controls.Add(label) Me.Text = "CheckBoxCell Demo" End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Dim checkBoxCell1 As New CalendarCheckBoxCellType() checkBoxCell1.ThreeState = True checkBoxCell1.TrueValue = "Yes" checkBoxCell1.FalseValue = "No" checkBoxCell1.IndeterminateValue = "Ignore" checkBoxCell1.Text = "State" checkBoxCell1.CheckAlign = ContentAlignment.MiddleRight Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate() template1.Content(1, 0).CellType = checkBoxCell1 template1.Content(2, 0).CellType = checkBoxCell1.Clone() gcCalendarGrid1.Template = template1 End Sub Private Sub gcCalendarGrid1_CellValueChanged(sender As Object, e As CalendarCellEventArgs) 'When the value commit, the actual stored value is TrueValue, FalseValue or IndeterminateValue. Dim currentCellValue As Object = Me.gcCalendarGrid1(gcCalendarGrid1.CurrentCellPosition.[Date])(gcCalendarGrid1.CurrentCellPosition.RowIndex, gcCalendarGrid1.CurrentCellPosition.ColumnIndex).Value If currentCellValue IsNot Nothing Then Me.label.Text = "The current parsed value is " + currentCellValue.ToString() End If End Sub <STAThreadAttribute> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New CheckBoxCellDemo()) End Sub End Class End Namespace
System.Object
GrapeCity.Win.CalendarGrid.CalendarCellType
GrapeCity.Win.CalendarGrid.CalendarButtonCellTypeBase
GrapeCity.Win.CalendarGrid.CalendarCheckBoxCellType