Problem deleting text

General TRichView support forum. Please post your questions here
Post Reply
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Problem deleting text

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Post 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! :)
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Post 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.
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Post 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.
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Post 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.
conciliator
Posts: 25
Joined: Thu Sep 17, 2009 7:50 am

Post by conciliator »

As suggested by Sergey, the problem was related to the desired text being protected. Case closed.
Post Reply