trichview.com

trichview.support




Re: ItemNo of inserted control


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/05/2003 18:48:25


Not all.


Items in RichView document are indexed from 0 to ItemCount-1.

But items inside tables cells are not included in this index range: cells

are subdocuments, they have their own item ranges from 0 to

cell.ItemCount-1.

You need to write a recursive procedure:


uses CRVData, RVItem;


function FindControlLocation(RVData: TCustomRVData; Ctrl: TControl;

  var CtrlRVData: TCustomRVData; var CtrlItemNo: Integer): Boolean;

var i,r,c: Integer;

    table: TRVTableItemInfo;

begin

  Result := False;

  for i := 0 to RVData.Items.Count-1 do begin

    if (RVData.GetItemStyle(i)=rvsComponent) and

       (TRVControlItemInfo(RVData.GetItem(i)).Control=Ctrl) then begin

      CtrlItemNo := i;

      CtrlRVData := RVData;

      exit;

    end;

    if (RVData.GetItemStyle(i)=rvsTable) then begin

      table := TRVTableItemInfo(RVData.GetItem(i));

      for r := 0 to table.Rows.Count-1 do

        for c := 0 to table.Rows[r].Count-1 do

          if (table.Cells[r,c]<>nil) then begin

             Result := FindControlLocation(table.Cells[r,c].GetRVData, Ctrl,

               CtrlRVData, CtrlItemNo);

             if Result then

               exit;

          end;

    end;

  end;

end;


This function must be called as shown below:


var CtrlRVData: TCustomRVData;

  CtrlItemNo: Integer;


if FindControlLocation(rv.RVData, Ctrl, CtrlRVData, CtrlItemNo) then begin

  xxx := CtrlRVData.GetItemTag(CtrlItemNo); // or something like this

end;

>

> > If controls are NOT in table cells, you can use FindControlItemNo

method.

> > Otherwise you need to iterate through all items (including table cells)

> to

> > find the control.

>

> They are in table cell.

> I see... what is the correct way to iterate through the items?

> Do all items of RichView document have ItemNo values from 0 to ItemCount?





Powered by ABC Amber Outlook Express Converter