Search code examples
c#winformsdevexpressrichedit-control

C# Change selection Font via Devexpress RichEditControl


I want to change some part of text in richEditControl Devexpress.

For Example this sentence.

"Kocaeli University Computer Engineering Department"

when i click a button this may can change that one.

"Kocaeli University Computer Engineering Department"

only some part of text can be Italic or other appearance.

thanks.


Solution

  • Example below shows how you can change selected texts italic property:

    //Gets selected text range
    DocumentRange range = richEditControl1.Document.Selection;
    //Begin selected text update
    CharacterProperties characterProperties = richEditControl1.Document.BeginUpdateCharacters(range);
    //Change font
    characterProperties.Italic = true;
    //End update
    richEditControl1.Document.EndUpdateCharacters(characterProperties);