GrapeCity.Win.CalendarGrid.v20 アセンブリ > GrapeCity.Win.CalendarGrid 名前空間 > CalendarCheckBoxCellType クラス : ThreeState プロパティ |
このプロパティの値が false の場合、セルの値は true または false に編集できます。
このプロパティの値が true の場合、セルの値は System.Windows.Forms.CheckState 値のいずれか 1 つに編集できます。System.Windows.Forms.CheckState.Checked は true、System.Windows.Forms.CheckState.Unchecked は false に相当し、System.Windows.Forms.CheckState.Indeterminate は値が true か false か明らかでないことを意味します。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