Perhaps rather than showing bad solutions, I should just state the problem
I wish to apply an arbitrary existing style to the text items in a table cell - the text items can be of any style (and multiple styles) and be unicode or not and the existing style I want to apply may be Unicode or not.
The items are originally inserted in the cell by a paste operation having been copied from 'outside' of the application.
I want to repeat this option for a full column in the table without having to do Format operations in between.
Dick
Change Font In Table Cell
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
And the winner is:
for i := Fmain.RichViewEdit1.ItemCount - 1 downto 0 do
begin
case Fmain.RichViewEdit1.GetItemStyle(i) of
rvsTable:
Table := TRVTableItemInfo(Fmain.RichViewEdit1.GetItem(i));
end;
end;
ItemNo := Fmain.RichViewEdit1.GetItemNo(table);
Fmain.RichViewEdit1.BeginItemModify(ItemNo, TableData);
MasterRVTable.SelectCols(1,1);
FMain.RichViewEdit1.ApplyTextStyle(2);
FMain.RichViewEdit1.Deselect;
FMain.RichViewEdit1.EndItemModify(ItemNo, TableData);
FMain.RichViewEdit1.Change;
FMain.RichViewEdit1.Format;
for i := Fmain.RichViewEdit1.ItemCount - 1 downto 0 do
begin
case Fmain.RichViewEdit1.GetItemStyle(i) of
rvsTable:
Table := TRVTableItemInfo(Fmain.RichViewEdit1.GetItem(i));
end;
end;
ItemNo := Fmain.RichViewEdit1.GetItemNo(table);
Fmain.RichViewEdit1.BeginItemModify(ItemNo, TableData);
MasterRVTable.SelectCols(1,1);
FMain.RichViewEdit1.ApplyTextStyle(2);
FMain.RichViewEdit1.Deselect;
FMain.RichViewEdit1.EndItemModify(ItemNo, TableData);
FMain.RichViewEdit1.Change;
FMain.RichViewEdit1.Format;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sorry for the delay, we were busy preparing a new beta update.
Your code is correct, this is the simplest way (and the user can undo this operation).
Converting the item to/from Unicode without editing methods require using undocumented features.
PS: your code reformat the editor 3 times
One time, ApplyTextStyle (it reformat the affected part of the document itself).
EndItemModify reformats the document one more time, if table width is changed.
And Format reformat the document one more time.
So all these methods can be removed (and Change too, because ApplyTextStyle, like any editing operation, calls Change)
Your code is correct, this is the simplest way (and the user can undo this operation).
Converting the item to/from Unicode without editing methods require using undocumented features.
PS: your code reformat the editor 3 times
One time, ApplyTextStyle (it reformat the affected part of the document itself).
EndItemModify reformats the document one more time, if table width is changed.
And Format reformat the document one more time.
So all these methods can be removed (and Change too, because ApplyTextStyle, like any editing operation, calls Change)
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
By the way, your code applies only to MasterRVTable, so the cycle to find table is not useful (and it returns only the first table in the document).
To apply to all tables, use this code:
To apply to all tables, use this code:
Code: Select all
for i := Fmain.RichViewEdit1.ItemCount - 1 downto 0 do
if Fmain.RichViewEdit1.GetItemStyle(i)=rvsTable then
begin
Table := TRVTableItemInfo(Fmain.RichViewEdit1.GetItem(i));
Table.SelectCols(1,1);
FMain.RichViewEdit1.ApplyTextStyle(2);
end;
FMain.RichViewEdit1.Deselect;
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
Thank you for your comments, Sergey - I will clean up the code as you suggest. Not necessary to do multiple tables - there is only ONE master .
Please see my new post, though - as I've decided it would be nice to allow the user to retain the 'font effects' and change only the typeface - this gets us back into the old issues...
Dick
Please see my new post, though - as I've decided it would be nice to allow the user to retain the 'font effects' and change only the typeface - this gets us back into the old issues...
Dick
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: