trichview.com

trichview.support




Re: Table row coluns count


Return to index


Author

Message

Pieter Zijlstra

Posted: 07/12/2005 22:24:48


Alexander Fatykhov wrote:


> How to get number of colunms in gives row?

Here is an example of getting the number of columns of the table row

where the caret is positioned.



function GetNumberOfTableColumns(RVE: TCustomRichViewEdit): Integer;

var

  MainRow, MainCol: Integer;

  Row, C, Col: Integer;

  RVCell: TRVTableCellData;

  RVCellLast: TRVTableCellData;

  RVEditor: TCustomRichViewEdit;

  RVItem: TCustomRVItemInfo;

  RVTable: TRVTableItemInfo;

begin

  Result := 0;


  if RVE.GetCurrentItemEx(TRVTableItemInfo, RVEditor, RVItem) then

  begin

    RVTable := TRVTableItemInfo(RVItem);

    if RVTable.GetEditedCell(Row, Col) <> nil then

    begin

      RVCellLast := nil;

      // Check all Columns for available cells (<> nil)

      for C := 0 to RVTable.Rows[Row].Count - 1 do

      begin

        RVCell := RVTable.Cells[Row, C];

        if RVCell <> nil then

        begin

          Inc(Result);

          RVCellLast := RVCell;

        end

        else

        begin

          // If no cell available check for possible main (merged) cells

          RVCell := RVTable.Rows.GetMainCell(Row, C, MainRow, MainCol);

          if RVCellLast <> RVCell then

          begin

            Inc(Result);

            RVCellLast := RVCell;

          end;

        end;

      end;

    end;

  end;

end;



--

Pieter





Powered by ABC Amber Outlook Express Converter