문제

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.

도움이 되었습니까?

해결책

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);

다른 팁

i try to this.

DocumentRange[] dr = richEditControl1.Document.FindAll("Computer Engineering", SearchOptions.None);
CharacterProperties cp = richEditControl1.Document.BeginUpdateCharacters(dr[0]);
cp.Italic = true;
richEditControl1.Document.EndUpdateCharacters(cp);

everything is good until when i change the text in richtextcontrol if i add only a letter or char in text that appearance "italic" is changed.

for example when i changed Computer Engineer to italic and add one letter or char to textcontrol the italic is go away.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top