Page 1 of 1

TCustomRichViewEdit.TopLevelEditor.Format is giving error

Posted: Tue Oct 02, 2012 10:50 am
by ranjanbag
Hi,

I have the following code in our application. But some time "TCustomRichViewEdit.TopLevelEditor.Format" it is throwing error - "List Index Out of bounds(-1).

Could you please tell me what is the solution?

Code: Select all

   CellData := BaseTable.Cells[CurrentRow, CurrentCol];

      CellData.Edit;

      RVData := CellData.GetRVData;

      for nIndex := 0 to RVData.ItemCount - 1 do
      begin
        if (RVData.GetItemStyle(nIndex) = rvsComponent) then
        begin
          if (TRVControlItemInfo(RVData.GetItem(nIndex)).Control is TStrikeThru) then
          begin
            if TStrikethru(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).IsFromNormal then
            begin
              if not (TStrikethru(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).IsFromFindingsLast) then { -ogay : added condition, so that the normals coming from load last will not return to normal state }
                TStrikethru(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).Status := 0;
            end
          end
          else if (TRVControlItemInfo(RVData.GetItem(nIndex)).Control is TSmartext) then
          begin
            if TSmartext(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).IsFromNormal then
            begin
              if not (TSmartext(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).IsFromFindingsLast) then { -ogay : added condition, so that the normals coming from load last will not return to normal state }
              begin
                TSmartext(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).TriggeredButton := 0;
                TSmartext(TRVControlItemInfo(RVData.GetItem(nIndex)).Control).MDOInvalidateSmartext;
              end;
            end;
          end;
        end;
      end;


      Editor.TopLevelEditor.Format;

      FixColors(Editor.TopLevelEditor);

      Editor.TopLevelEditor.Format;

      CellData.Edit;

Posted: Tue Oct 02, 2012 12:19 pm
by Sergey Tkachenko
I am afraid I have not enough information to find the reason of this problem.
Please create a simple project (without non-standard controls) reproducing this problem and send it to me.

I can see one possible problem: even after calling CellData.Edit, it's not necessary that Editor.TopLevelEditor is an inplace editor of this cell. It may be an inplace editor of a cell of another table inserted in CellData.