Cursor and Font in table setting...

General TRichView support forum. Please post your questions here
Post Reply
Crowbar
Posts: 82
Joined: Wed Oct 11, 2006 8:54 pm
Location: Germany

Cursor and Font in table setting...

Post by Crowbar »

Hello,
i have ask two:

1.
I insert a new table in my RichViewEdit with following code:

Code: Select all

...
RichViewEdit.InsertItem('',Table);
...
This works fine, but the cursor in my RichViewEdit is after the table.
How do I get the cursor into the first cell of the table (Table.Cells[0,0]...)?

2.
With the following code, I reading the current FontInfo and set these for the new table:

Code: Select all

...
TabFontInfo:=RVStyle.TextStyles[RichViewEdit.CurTextStyleNo];
RichViewEdit.ApplyTextStyle(RichViewEdit.CurTextStyleNo);
RVStyle.TextStyles[0].FontName:=TabFontInfo.FontName;
RVStyle.TextStyles[0].Size:=TabFontInfo.Size;
RichViewEdit.InsertItem('',Table);
...
This works fine until another table is inserted, with another current FontInfo (example:first table fontsize = 10; second table fontsize = 7).
Both tables abruptly have fontsize = 7 after it.

I hope that you understood my questions? :roll:
My English is not so good. :oops:

Greetings
Crowbar
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

for r := 0 to table.RowCount-1 do
  for c := 0 to table.ColCount-1 do
    if table.Cells[r,c]<>nil then begin
      table.Cells[r,c].Clear;
      table.Cells[r,c].AddNLATag('', 
        RichViewEdit.CurTextStyleNo, RichViewEdit.CurParaStyleNo, 0);
    end;
if RichViewEdit.InsertItem('', table) then
  table.EditCell(0,0);
You should not modify properties of existing styles, these changes will affect all text using this text style.
Each table cell initially has one empty text item of the 0th text and paragraph style. The code above replaces them with text items of the current text and paragraph styles.

RowCount and ColCount properties are introduced in TRichView v1.9.20.
If you use older version, change them to Rows.Count and Rows[r].Count.
Crowbar
Posts: 82
Joined: Wed Oct 11, 2006 8:54 pm
Location: Germany

Post by Crowbar »

Hi Sergey,
thank you for your informations and help!

It works fine! :D

Greetings
Crowbar
Post Reply