Replace color in all records fon a DBRichViewEdit
Posted: Tue Jun 04, 2013 1:11 pm
Hello,
i should replace a text-color with another color in all records for a DBRichViewEdit. The data is stored in RTF-format.
Here http://www.trichview.com/forums/viewtopic.php?t=612 is an example for changing the font-size globally, but i can't get it to work.
If i run my routine, nothing happens, no color change, no error
Here is my code (due to this code should run in an update-routine, i can' t use the existing Table/Datasource/DBRichViewEdit-controls exept of the RVStyle), i copied all properties from the existing controls.
Does anybody have an idea where my problem or error is ?
Greetings
Bjoern
i should replace a text-color with another color in all records for a DBRichViewEdit. The data is stored in RTF-format.
Here http://www.trichview.com/forums/viewtopic.php?t=612 is an example for changing the font-size globally, but i can't get it to work.
If i run my routine, nothing happens, no color change, no error
Here is my code (due to this code should run in an update-routine, i can' t use the existing Table/Datasource/DBRichViewEdit-controls exept of the RVStyle), i copied all properties from the existing controls.
Code: Select all
MyTable := TTable.Create(Self);
MyTable.TableName := MyTableName;
MyDataSource := TDataSource.Create(Self);
MyDataSource.DataSet := MyTable;
MyDBRichViewEdit := TDBRichViewEdit.Create(Self);
MyDBRichViewEdit.DataField := 'Text';
MyDBRichViewEdit.DataSource := MyDataSource;
MyDBRichViewEdit.ReadOnly := False;
MyDBRichViewEdit.FieldFormat := rvdbRTF;
MyDBRichViewEdit.RTFOptions := [rvrtfSaveStyleSheet, rvrtfDuplicateUnicode, rvrtfSaveEMFAsWMF, rvrtfSaveJpegAsJpeg];
MyDBRichViewEdit.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
MyDBRichViewEdit.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
MyDBRichViewEdit.Style := MyForm.RVStyle1;
MyDBRichViewEdit.Visible := False;
MyDBRichViewEdit.Parent := MyForm;
MyTable.Open;
MyTable.First;
Counter := MyTable.RecordCount;
for i := 1 to Counter do
begin
Mytable.Edit;
MyDBRichViewEdit.CanChange;
for j := 0 to MyForm.RVStyle1.TextStyles.Count-1 do
begin
if (MyForm.RVStyle1.TextStyles[j].Color =MyOldColor) then
begin
MyForm.RVStyle1.TextStyles[j].Color := MyNewColor
end;
end;
MyDBRichViewEdit.Change;
MyDBRichViewEdit.Format;
MyTable.Post;
MyTable.Next;
end;
MyTable.Close;
MyTable.Free;
MyDataSource.Free;
MyDBRichViewEdit.Free;
Greetings
Bjoern