Hi,
We are upgrading our application for rich text editing. In the old versions there were just plain text with dbmemo, now there should be some formatting and I want to use the TJvRichEdit for this.
The problem: The texts that already exists in the database is plaintext. When I open a mask and don't change anything in the richEdit, its still plaintext without the rtf formatting tags.
What I need: the old plain text should be automatically converted to rtf text after displaying. (I mean, I open a mask with a richEdit which displays plaintext, and at this moment the plaintext should be enhanced with the rtf tags and saved to the databse).
For this purpose I've created a descendant of the TDBRichEdit. But I have problems to finda propper place to make this happebs.
For now, I've overwritten the setBounds method with the following code:
procedure TMyRichEdit.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
inherited;
...
if (assigned(DataSource)) AND (assigned(DataSource.DataSet)) AND
(self.Text <> '') AND
(LeftStr(sDataSource.DataSet.FieldByName(DataField).AsString, 5) <> '{\rtf') then
begin
self.DataSource.DataSet.Edit;
// After a call to UpdateMemo the plaintext gets extended with the rtf tags
self.UpdateMemo;
self.DataSource.DataSet.Post;
self.DataSource.DataSet.Edit;
end;
...
end;
So this works, but only if the richEdit has an anchor set. If not it doesn't work. I know thats the wrong place for this code, I've tried overwrite more propper methods but without access. How can I solve something like this? Thanks guys!