ShowFontFormCommand.ForceExecute(ICommandUIState) Method
Executes the command specifying the UI state explicitly.
Namespace: DevExpress.XtraRichEdit.Commands
Assembly: DevExpress.RichEdit.v24.1.Core.dll
NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation
Declaration
Parameters
Name | Type | Description |
---|---|---|
state | ICommandUIState | An object which implements the ICommandUIState interface. |
Remarks
The Command.Execute method performs the UI state check implicitly, so you cannot bring the command to action arbitrarily. Unlike the Execute method, the ForceExecute method enables you to check the UI state for the command, and then deliberately and unconditionally start its execution, or decline it.
The following code sample illustrates how you can invoke the Font form for the read-only RichEdit control, to change the selection font. You can check the ICommandUIState of the command., decide whether it should be changed and change it to execute the command.
using DevExpress.Utils.Commands;
using DevExpress.XtraRichEdit.Commands;
// ...
ShowFontFormCommand cmd = new ShowFontFormCommand(richEditControl1);
ICommandUIState state = cmd.CreateDefaultCommandUIState();
cmd.UpdateUIState(state);
if (!state.Enabled && richEditControl1.ReadOnly) state.Enabled = true;
cmd.ForceExecute(state);