0

Is it possible to programmatically change current font color in the document?

By this I don't mean changing color of specific selection of the document. I need to have all text written by user in blue color. Is it possible to programmatically change input color to blue?

I tried using the ChangeFontColorCommand, but I couldn't find the right way to use it. This code simulates the command used by toolbar button:

var command = new ChangeFontColorCommand(RichEdit);
var uiState = (IValueBasedCommandUIState<Color>) command.CreateDefaultCommandUIState();
uiState.EditValue = Color.Blue;
command.ForceExecute(uiState);

Is it possible to have all text written by user in blue? How? Any help would be appreciated.

Tom Pažourek
  • 9,582
  • 8
  • 66
  • 107

1 Answers1

0

Does the Document.DefaultCharacterProperties property suits your needs?
Please try the following:

richEditControl.Document.DefaultCharacterProperties.ForeColor = Color.Blue;
DmitryG
  • 17,677
  • 1
  • 30
  • 53
  • Thanks for suggestion. Sadly, this property changes nothing at all. I think it only changes the default format. That means that the text will be blue only when I select it and apply ClearFormattingCommand. – Tom Pažourek May 24 '12 at 08:07