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.
TDBRichviewEdit new color style
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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:
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;