officefileapi-devexpress-dot-xtrarichedit-dot-commands-22f4e6a2.md
A command to change the font color of the selected text.
Namespace : DevExpress.XtraRichEdit.Commands
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
public class ChangeFontColorCommand :
ChangeCharacterFormattingCommandBase<Color>
Public Class ChangeFontColorCommand
Inherits ChangeCharacterFormattingCommandBase(Of Color)
The following code paints the selected text red:
using DevExpress.Utils.Commands;
using DevExpress.XtraRichEdit.Commands;
// ...
ChangeFontColorCommand cmd = new ChangeFontColorCommand(richEditControl1);
ICommandUIState state = cmd.CreateDefaultCommandUIState();
cmd.UpdateUIState(state);
if (!state.Enabled && richEditControl1.ReadOnly) state.Enabled = true;
state.EditValue = Color.Red;
cmd.ForceExecute(state);
Imports DevExpress.Utils.Commands
Imports DevExpress.XtraRichEdit.Commands
' ...
Dim cmd As ChangeFontColorCommand = New ChangeFontColorCommand(richEditControl1)
Dim state As ICommandUIState = cmd.CreateDefaultCommandUIState()
cmd.UpdateUIState(state)
If (Not state.Enabled) AndAlso richEditControl1.ReadOnly Then
state.Enabled = True
state.EditValue = Color.Red
End If
cmd.ForceExecute(state)
Object Command DevExpress.Utils.Commands.ControlCommand<IRichEditControl, RichEditCommandId, DevExpress.XtraRichEdit.Localization.XtraRichEditStringId> DevExpress.XtraRichEdit.Commands.RichEditCommandBase<DevExpress.XtraRichEdit.Localization.XtraRichEditStringId> RichEditCommand DevExpress.XtraRichEdit.Commands.SelectionBasedCommandBase SelectionBasedPropertyChangeCommandBase DevExpress.XtraRichEdit.Commands.ChangeCharacterFormattingCommandBase<Color> ChangeFontColorCommand
See Also