Table in table again

General TRichView support forum. Please post your questions here
Post Reply
delphilord
Posts: 25
Joined: Thu Feb 02, 2006 6:53 am
Contact:

Table in table again

Post by delphilord »

i have a table in document.it is first item.(itemno=0).
let's name it table_A.
in cell [2,2] of this table I have another table.Table_B.it is second item in this cell.
I want to add rows to this table_B that is in one of Table_A cells.
how to get cell as richview control? any other possible solution?
what is the best way to do this?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Is the table in TRichViewEdit or in TRichView?
If in TRichViewEdit, should it be an editing operation (undoable by the user)
delphilord
Posts: 25
Joined: Thu Feb 02, 2006 6:53 am
Contact:

Post by delphilord »

trichview.
No user action needed.Document build by code,and user can not edit it.
delphilord
Posts: 25
Joined: Thu Feb 02, 2006 6:53 am
Contact:

Post by delphilord »

I think this way
1-Getting parent (outer) table item - It is easy
2-moving in to cell[2,2] HOW?
3-geting table again
4-add row

is it possible to get inplace editor for desired cell and get table in it?
delphilord
Posts: 25
Joined: Thu Feb 02, 2006 6:53 am
Contact:

Post by delphilord »

Sorry I don't want to spam. but I can use trichview or read only trichviewedit.
any solution with this two possiblity
delphilord
Posts: 25
Joined: Thu Feb 02, 2006 6:53 am
Contact:

Post by delphilord »

I found a working but very unclear solution.Also I am not it is safe,Sure they must be clear and clever code to do this

Code: Select all

 rve.SetSelectionBounds(0,0,0,1);
     if not Rve.CanChange or
     not rve.GetCurrentItemEx(TRVTableItemInfo, rve2, item)  then Exit;
     tableX := TRVTableItemInfo(item);
    // ItemNo := rve.GetItemNo(tablex);
    // rve2.BeginItemModify(ItemNo, Data);
    c:=2;
    r:=2;
    RVData := tablex.Cells[r,c]; // or RichViewEdit1.RVData
    RVData := TCustomRVFormattedData(RVData).Edit;
    if tablex.getEditedCell(r,c)=nil then  exit;
    Rve3:= tablex.getEditedCell(r,c);
    rve3.SetSelectionBounds(GlobalTableno,0,GlobalTableno,1);
    if not Rve3.CanChange or
    not rve3.GetCurrentItemEx(TRVTableItemInfo, rve4, item)  then Exit;
    tablex := TRVTableItemInfo(item);
    ItemNo := rve4.GetItemNo(tablex);
    RVData := tablex.Cells[tablex.RowCount -2,0]; // or RichViewEdit1.RVData
    RVData := TCustomRVFormattedData(RVData).Edit;

    rve4.BeginItemModify(ItemNo, Data);

     tablex.InsertRowsBelow(1);
......
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

A solution using cell editing is for non-readonly TRichViewEdit.
As for TRichView,

Code: Select all

Table_A := RichView1.GetItem(0) as TRVTableItemInfo;
Table_B := Table_A.Cells[2,2].GetRVData.GetItem(1) as TRVTableItemInfo;
Table_B.InsertRows(...);
RichView1.Format;
Post Reply