windowsforms-devexpress-dot-xtraeditors-dot-checkedit-12d4d915.md
Gets or sets whether the check editor is in the checked state.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DefaultValue(false)]
[DXCategory("Appearance")]
public virtual bool Checked { get; set; }
<DXCategory("Appearance")>
<DefaultValue(False)>
Public Overridable Property Checked As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true if the editor is checked; otherwise, false.
|
Typically, you use the Checked property to specify the editor’s check state when the RepositoryItemCheckEdit.AllowGrayed setting is disabled. In this mode, the editor only supports the checked and unchecked states, which correspond to the Checked property being set to true and false , respectively.
To specify a check state in three-state mode (checked, unchecked and indeterminate), use the CheckEdit.CheckState property instead.
In three-state mode, if the CheckEdit.CheckState property value is CheckState.Indeterminate , the Checked property returns true.
In the CheckEdit control, each check state is associated with a certain value (by default, the checked and unchecked states are associated with true and false ; the indeterminate state is associated with null ). When you modify the check state, the control’s edit value (CheckEdit.EditValue) is set to a corresponding value, and vice versa. See the CheckEdit.EditValue topic to learn more.
This example demonstrates how to programmatically create two check editors, initialize their properties and assign the same handler for their CheckEdit.CheckedChanged events. The created check editors will be used to control the visibility and availability of a standard button control. The example implies that the button is already placed onto a form.
Changing the check state of the first check editor affects both the button’s visibility and the second check editor’s availability. The second check editor specifies the availability of the button for end-users.
The image below displays the example application.
using DevExpress.XtraEditors;
using DevExpress.Utils;
private void CreateCheckEditors() {
// creating and initializing the first check editor
CheckEdit chEdit1 = new CheckEdit();
chEdit1.Properties.Caption = "Hide Button";
chEdit1.Name = "chEdit1";
chEdit1.Location = new System.Drawing.Point(6, 35);
chEdit1.Width = 100;
// setting the editor's check state depending upon the button's visibility
if (!(button1.Visible)) chEdit1.Checked = true;
// assigning a handler for the CheckChanged event of the first check editor
chEdit1.CheckedChanged += new EventHandler(CheckedChanged);
this.Controls.Add((Control)chEdit1);
// creating and initializing the second check editor
CheckEdit chEdit2 = new CheckEdit();
chEdit2.Properties.Caption = "Disable Button";
chEdit2.Name = "chEdit2";
chEdit2.Location = new System.Drawing.Point(6, 55);
chEdit2.Width = 100;
// setting the editor's check state depending upon the button's availability
if (!(button1.Enabled)) chEdit2.Checked = true;
if (!(button1.Visible)) chEdit2.Enabled = false;
// assigning a handler for the CheckChanged event of the second check editor
chEdit2.CheckedChanged += new EventHandler(CheckedChanged);
this.Controls.Add((Control)chEdit2);
}
private void CheckedChanged(object sender, System.EventArgs e) {
CheckEdit edit = sender as CheckEdit;
switch (edit.Checked) {
case true:
if (edit == GetCheckEdit("chEdit1")){
// hiding the button
button1.Visible = false;
// disabling the second check editor
GetCheckEdit("chEdit2").Enabled = false;
}
else if (edit == GetCheckEdit("chEdit2")){
// enabling the button
button1.Enabled = false;
}
break;
case false:
if (edit == GetCheckEdit("chEdit1")){
// showing the button
button1.Visible = true;
// enabling the second check editor
GetCheckEdit("chEdit2").Enabled = true;
}
else if (edit == GetCheckEdit("chEdit2")){
// disabling the button
button1.Enabled = true;
}
break;
}
}
private CheckEdit GetCheckEdit(string editName){
foreach(Control control in this.Controls){
if ((control is CheckEdit) && (control.Name == editName))
return control as CheckEdit;
}
return null;
}
Imports DevExpress.XtraEditors
Imports DevExpress.Utils
Private Sub CreateCheckEditors()
' creating and initializing the first check editor
Dim ChEdit1 As New CheckEdit()
ChEdit1.Properties.Caption = "Hide Button"
ChEdit1.Name = "ChEdit1"
ChEdit1.Location = New System.Drawing.Point(6, 35)
ChEdit1.Width = 100
' setting the editor's check state depending upon the button's visibility
If Not Button1.Visible Then ChEdit1.Checked = True
' assigning a handler for the CheckChanged event of the first check editor
AddHandler ChEdit1.CheckedChanged, AddressOf CheckedChanged
Me.Controls.Add(CType(ChEdit1, Control))
' creating and initializing the second check editor
Dim ChEdit2 As New CheckEdit()
ChEdit2.Properties.Caption = "Disable Button"
ChEdit2.Name = "ChEdit2"
ChEdit2.Location = New System.Drawing.Point(6, 55)
ChEdit2.Width = 100
' setting the editor's check state depending upon the button's availability
If Not Button1.Enabled Then ChEdit2.Checked = True
If Not Button1.Visible Then ChEdit2.Enabled = False
' assigning a handler for the CheckChanged event of the second check editor
AddHandler ChEdit2.CheckedChanged, AddressOf CheckedChanged
Me.Controls.Add(CType(ChEdit2, Control))
End Sub
Private Sub CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Edit As CheckEdit = CType(sender, CheckEdit)
Select Case Edit.Checked
Case True
If Edit Is GetCheckEdit("ChEdit1") Then
' hiding the button
Button1.Visible = False
' disabling the second check editor
GetCheckEdit("ChEdit2").Enabled = False
ElseIf Edit Is GetCheckEdit("ChEdit2") Then
' enabling the button
Button1.Enabled = False
End If
Case False
If Edit Is GetCheckEdit("ChEdit1") Then
' showing the button
Button1.Visible = True
' enabling the second check editor
GetCheckEdit("ChEdit2").Enabled = True
ElseIf Edit Is GetCheckEdit("chEdit2") Then
' disabling the button
Button1.Enabled = True
End If
End Select
End Sub
Private Function GetCheckEdit(ByVal editName As String) As CheckEdit
Dim Control As Control
For Each Control In Me.Controls
If TypeOf Control Is CheckEdit And Control.Name = editName Then
Return CType(Control, CheckEdit)
EndIf
Next
Return Nothing
End Function
The following code snippets (auto-collected from DevExpress Examples) contain references to the Checked property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
colorEdit2.Enabled = userColors;
customColorsCheckEdit.Checked = userColors;
absoluteLevelsEdit.Enabled = !percents;
winforms-richedit-layout-api/CS/Form1.cs#L140
{
customDrawText = checkEdit1.Checked ? true : false;
richEditControl1.Refresh();
winforms-memo-editor-advanced-mode/CS/MemoEditSample/Views/DemoView.cs#L23
fluent.SetBinding(ce1K, ce => ce.Checked, x => x.Use1K);
fluent.SetBinding(ce10K, ce => ce.Checked, x => x.Use10K);
winforms-scheduler-sync-outlook-calendars/CS/SyncWithOutlook/Form1.cs#L31
synchronizerHelper = new OutlookSynchronizerHelper(schedulerControl1.Storage, "", OutlookEntryIDFieldName);
checkEdit1.Checked = true;
}
controller.SetLabel(edLabel.AppointmentLabel);
controller.AllDay = this.checkAllDay.Checked;
controller.Start = this.dtStart.DateTime.Date + this.timeStart.Time.TimeOfDay;
colorEdit2.Enabled = userColors
customColorsCheckEdit.Checked = userColors
absoluteLevelsEdit.Enabled = Not percents
winforms-richedit-layout-api/VB/Form1.vb#L116
Private Sub checkEdit1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles checkEdit1.CheckedChanged
customDrawText = If(checkEdit1.Checked, True, False)
richEditControl1.Refresh()
winforms-memo-editor-advanced-mode/VB/MemoEditSample/Views/DemoView.vb#L26
fluent.SetBinding(ce1K, Function(ce) ce.Checked, Function(x) x.Use1K)
fluent.SetBinding(ce10K, Function(ce) ce.Checked, Function(x) x.Use10K)
winforms-scheduler-sync-outlook-calendars/VB/SyncWithOutlook/Form1.vb#L33
synchronizerHelper = New OutlookSynchronizerHelper(schedulerControl1.Storage, "", OutlookEntryIDFieldName)
checkEdit1.Checked = True
End Sub
controller.SetLabel(edLabel.AppointmentLabel)
controller.AllDay = Me.checkAllDay.Checked
controller.Start = Me.dtStart.DateTime.Date + Me.timeStart.Time.TimeOfDay
See Also