RepositoryItemToggleSwitch.GetStateByValue(Object) Method
Converts a specific ToggleSwitch edit value to a boolean value.
Namespace: DevExpress.XtraEditors.Repository
Assembly: DevExpress.XtraEditors.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Parameters
Name | Type | Description |
---|---|---|
value | Object | An Object that is the value to be checked. |
Returns
Type | Description |
---|---|
Boolean | true if the target value corresponds to the “checked” ToggleSwitch state; false if the value corresponds to the “unchecked” state or is not identified. |
Remarks
By default, toggling a ToggleSwitch editor on or off switches the value of its EditValue property between true and false respectively. If you need to assign custom values for these states, utilize the RepositoryItemToggleSwitch.ValueOn and RepositoryItemToggleSwitch.ValueOff properties.
To retrieve a value associated with a specific editor state, call the RepositoryItemToggleSwitch.GetValueByState method. Vice versa, to get an editor state associated with a specific value, call the RepositoryItemToggleSwitch.GetStateByValue
method.
toggleSwitch1.Properties.ValueOff = "Disabled";
toggleSwitch1.Properties.ValueOn = "Enabled";
var a = toggleSwitch1.Properties.GetValueByState(false); // returns "Disabled"
var b = toggleSwitch1.Properties.GetStateByValue("Enabled"); // returns true
var c = toggleSwitch1.Properties.GetStateByValue("Activated"); // returns false