TDBRichviewEdit new color style

General TRichView support forum. Please post your questions here
Post Reply
jota
Posts: 48
Joined: Fri Sep 16, 2011 10:56 am

TDBRichviewEdit new color style

Post by jota »

Hi

In an empty TDBRichviewEdit i click on a button for change color style, but when i write, the characters appears in default color style.

If after writting i click on color style button other time, the next characters i write appears in the new color style.

Why occurs this behaviour? How i can do so that is written from the first character with the new color style?.

Can anyone help?.

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Right click TDBRichViewEdit at designtime, choose "Settings" in the context menu.
Select "Allow adding styles dynamically" and press OK.
jota
Posts: 48
Joined: Fri Sep 16, 2011 10:56 am

Post by jota »

Hello

"Allow adding styles dynamically" was already selected.

I can add the new style, but only after having written some character in the TDBRichviewEdit (If this is empty does not work)

Is there a property, configuration, etc. that causes this behavior?

Thanks
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

When the table is changed to an editing state, the editor may reload data from the database. In this case, all changes to styles will be lost, because they will be replaced to styles loaded from the database.

Normally, it does not happen, because the recommended way to apply text or paragraph changes, such as color, is doing it inside OnStyleConversion/OnParaStyleConversion. These events are called from ApplyStyleConversion/ApplyParaStyleConversion, when the editor is ready to accept changes.

However, it may be a problem when you use ApplyTextStyle, ApplyParaStyle, or ApplyListStyles. These methods assume that you add a new style before their execution.
To solve the problem, call editor.CanChange before the operation:

Code: Select all

if dbrve.CanChange then begin
  <add new style here>
  dbrve.ApplyTextStyle(...)
end;
Post Reply