Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RepositoryItemToggleSwitch.GetValueByState(Boolean) Method

Converts a boolean value to the corresponding ToggleSwitch edit value.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public object GetValueByState(
    bool state
)

#Parameters

Name Type Description
state Boolean

true, to retrieve the ToggleSwitch edit value when the editor is “checked”; otherwise, false.

#Returns

Type Description
Object

An Object that is the ToggleSwitch edit value associated with the required boolean value.

#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
See Also