Page 1 of 1
Problem deleting text
Posted: Fri Nov 27, 2009 3:03 pm
by conciliator
I've programatically selected some text using SetSelectionBounds, and now I wish to delete the selected text.
I'm trying
Code: Select all
if self.rveEditor.SelectionExists then begin
MessageDlg(IntToStr(Length(self.rveEditor.GetSelText)),
mtInformation,
[mbOk],
0);
self.rveEditor.DeleteSelection;
self.rveEditor.Format;
end;
but the text is not deleted. The message box returns 25. What am I doing wrong?
Posted: Fri Nov 27, 2009 4:35 pm
by Sergey Tkachenko
May be this text is protected, or rveEditor.ReadOnly = True?
PS: Format is not needed after DeleteSelection, because DeleteSelection is an editing method.
Posted: Mon Nov 30, 2009 9:28 am
by conciliator
Sergey, you seem to have answered me while I was writing a follow up:
"Problem is, perhaps, that the selected text is protected using styles. I've turned off the rvpaoStyleProtect, and I've tried to set the selected text to another style (where among rvpaoReadOnly and rvprModifyProtect and rvprDeleteProtect are turned off) using code. Unfortunately, I'm unable to set the desired styels using ApplyParaStyle(); and ApplyTextStyle();. It just won't change.
What's more, I find that the CurTextStyleNo property does not hold the correct information... Obviously, I'm experiencing some newbie problems, as such a sever bug would certainly be rectified by now."
To answer your answer, I've checked rveEditor.ReadOnly = False. I'll continue to investigate my protected/unable to change styles problem, but please come through if you have any input. Thanks in advance!
Posted: Mon Nov 30, 2009 9:44 am
by conciliator
Regarding the rvpaStyleProtect := False and me being unable to change styles, I realised that the rvprStyleProtect was set to true. Thus, I'm now able to change both text and paragraph style.
To be continued.
Posted: Mon Nov 30, 2009 9:47 am
by conciliator
For some absurd reason, the rvprStyleProtect := False seems to have corrected the apparent problem with CurTextStyleNo as well.
Once again; to be continued.
Posted: Mon Nov 30, 2009 9:55 am
by conciliator
I take that back, it was the rvprDoNotAutoSwitch := True (which Sergey has recomended setting to False for the default style) which caused the problem of erroneous result from CurTextStyleNo.
Posted: Mon Nov 30, 2009 12:03 pm
by conciliator
As suggested by Sergey, the problem was related to the desired text being protected. Case closed.