TRVTableItemInfo become empty after formatting document!

General TRichView support forum. Please post your questions here
Post Reply
mamouri
Posts: 63
Joined: Sat Aug 19, 2006 5:06 am

TRVTableItemInfo become empty after formatting document!

Post by mamouri »

Dear Sergey
I faced an odd problem with TRVTableItemInfo. I have a global variable named ATable. I add content to this private variable some text and add it to RichView and finally format the document.

After this when I want to get an item in a cell of a table, the cell is always empty. Here is the code that I use for getting count of the items in a table cell:

Code: Select all

var
  StartRow, StartCol, RowOffs, ColOffs: Integer;
begin
  ATable.GetSelectionBounds(StartRow, StartCol, RowOffs, ColOffs);
  Caption := IntToStr(ATable.Cells[StartRow, StartCol].ItemCount);
This always return 0. but it's not true and my cell include lot's of item. If I don't add table to Richview and get count of my cells it get me correct information but after adding table to richview and formating richview it always return 0.

I must mention that StartRow and StartCol are referencing correct table cell.
Why this happen? Are u have an idea?


Thank you :roll:
mamouri
Posts: 63
Joined: Sat Aug 19, 2006 5:06 am

Post by mamouri »

After lot's of confusion and reading richview help I found the problem. Here is what RichView help say:
When inplace editor is initiated, RichViewEdit moves all contents of the cell to this editor. When editor is destroyed, RichViewEdit moves modified data back to the cell (this procedure is transparent for user).
So if you wish to access directly to cell contents, use methods of cell's GetRVData instead of methods of cell.
So I changed my code like this:

Code: Select all

var
  StartRow, StartCol, RowOffs, ColOffs: Integer;
begin
  ATable.GetSelectionBounds(StartRow, StartCol, RowOffs, ColOffs);
  Caption := IntToStr(ATable.Cells[StartRow, StartCol].GetRVData.ItemCount);
It work find now BUT it raise an exception without any reason.
Is there another problem with my code?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This code is correct.
May be this cell is deleted because of cell merging?
Check if ATable.Cells[StartRow, StartCol]<>nil
Post Reply