Page 1 of 1

Cursor and Font in table setting...

Posted: Wed Nov 01, 2006 11:16 pm
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

Posted: Thu Nov 02, 2006 8:09 am
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.

Posted: Thu Nov 02, 2006 11:06 am
by Crowbar
Hi Sergey,
thank you for your informations and help!

It works fine! :D

Greetings
Crowbar