I am loading a .rvf file into a TSRichViewEdit control. The .rvf file consists of one table with two rows and two columns where I merged the first column for both rows.
After I load the file I am trying to delete the second row like this...
for i := RVData.ItemCount - 1 downto 0 do
begin
Style := RVData.GetItemStyle(i);
if Style = rvsTable then
begin
Table := TRVTableItemInfo(RVData.GetItem(i));
for Row := Table.RowCount - 1 downto 0 do
begin
// Delete all but the first row in the table
if Row > 0 then
begin
Table.Rows.Delete(Row);
end;
end;
end;
end;
When I call TSRichViewEdit.Format I get this error...
exception message : List index out of bounds (1).
Main ($1168):
00472055 UaarSales.exe Classes 2992 TList.Get
00bb6582 UaarSales.exe RVClasses 278 TRVIntegerList.Get
00c00b9c UaarSales.exe RVTable 7236 ExpandRows
00c01800 UaarSales.exe RVTable 7509 TRVTableItemInfo.InternalOnDocWidthChange
00bfef08 UaarSales.exe RVTable 6537 TRVTableItemInfo.OnDocWidthChange
00c31e0c UaarSales.exe CRVFData 2840 TCustomRVFormattedData.FormatLine
00c3351c UaarSales.exe CRVFData 3511 TCustomRVFormattedData.Format_
00bd177f UaarSales.exe RVERVData 5204 TRVEditRVData.Format_
004081b5 UaarSales.exe System 17866 @IntfCopy
00c25e14 UaarSales.exe RichView 1751 TCustomRichView.Format_
00c25bc2 UaarSales.exe RichView 1374 TCustomRichView.Format
00cd97d9 UaarSales.exe SclRView 13674 TSRichViewEdit.SetRVMargins
00cd9f85 UaarSales.exe SclRView 14131 TSRichViewEdit.Format
How can I delete the second row without getting this error?
I have a sample application that produces the error if it will help.
Delete Table Rows causes List index out of bounds error
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I spoke too soon. I am still getting list index out of bounds errors as soon as I call the DeleteRows method you recommended.
Our problem is we are in view mode not in edit mode. we need a way to delete the rows before Format is called. We are performing a mail merge trying to delete empty rows in the table as we are filling it but before we call format and display the report.
I tried to make public the TRVTableRows.DeleteRows procedure like this...
myTRVTableRows = class (TRVTableRows)
public
procedure DeleteRows(Index, Count: Integer; DecreaseHeight: Boolean);
end;
I was hoping this would delete the rows without worrying about editors or undo lists but I got the error "Can't modify empty undo list."
I am looking at the documentation but how do you delete rows when you're doing a mail merge before calling Format?
Our problem is we are in view mode not in edit mode. we need a way to delete the rows before Format is called. We are performing a mail merge trying to delete empty rows in the table as we are filling it but before we call format and display the report.
I tried to make public the TRVTableRows.DeleteRows procedure like this...
myTRVTableRows = class (TRVTableRows)
public
procedure DeleteRows(Index, Count: Integer; DecreaseHeight: Boolean);
end;
I was hoping this would delete the rows without worrying about editors or undo lists but I got the error "Can't modify empty undo list."
I am looking at the documentation but how do you delete rows when you're doing a mail merge before calling Format?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I tried that but I still get the List index out of bounds error when it paints after using the DeleteRows method in the FillFields routine...
exception message : List index out of bounds (16).
Main ($160c):
00472055 UaarSales.exe Classes 2992 TList.Get
00ca2246 UaarSales.exe RVItem 5770 TRVItemList.GetObject
00c63f6d UaarSales.exe CRVData 8421 TCustomRVData.GetItem
00c591e2 UaarSales.exe CRVData 4396 TCustomRVData.IsParaStart
00c41baa UaarSales.exe CRVFData 10084 TCustomRVFormattedData.IsParaStartEx
00c3667c UaarSales.exe CRVFData 4811 DrawParagraphsBacks
00c38f19 UaarSales.exe CRVFData 5573 TCustomRVFormattedData.PaintTo
00bea192 UaarSales.exe RVRVData 383 TRichViewRVData.UseStyleTemplates
00cc954d UaarSales.exe SclRView 8276 TSRichViewEdit.PaintPage
I did get it working without error but you might not like how I did it.
I derived from your TRVTableRows class like this...
myTRVTableRows = class (TRVTableRows)
public
procedure DeleteRows(Index, Count: Integer; DecreaseHeight: Boolean);
end;
Then I removed all the calls in myTRVTableRows.DeleteRows that updated the undo list.
This seems to work perfect. We've tested it with all the RichView document templates we've created and with various data and all of our tables display and roll up the data without any problems so far.
exception message : List index out of bounds (16).
Main ($160c):
00472055 UaarSales.exe Classes 2992 TList.Get
00ca2246 UaarSales.exe RVItem 5770 TRVItemList.GetObject
00c63f6d UaarSales.exe CRVData 8421 TCustomRVData.GetItem
00c591e2 UaarSales.exe CRVData 4396 TCustomRVData.IsParaStart
00c41baa UaarSales.exe CRVFData 10084 TCustomRVFormattedData.IsParaStartEx
00c3667c UaarSales.exe CRVFData 4811 DrawParagraphsBacks
00c38f19 UaarSales.exe CRVFData 5573 TCustomRVFormattedData.PaintTo
00bea192 UaarSales.exe RVRVData 383 TRichViewRVData.UseStyleTemplates
00cc954d UaarSales.exe SclRView 8276 TSRichViewEdit.PaintPage
I did get it working without error but you might not like how I did it.
I derived from your TRVTableRows class like this...
myTRVTableRows = class (TRVTableRows)
public
procedure DeleteRows(Index, Count: Integer; DecreaseHeight: Boolean);
end;
Then I removed all the calls in myTRVTableRows.DeleteRows that updated the undo list.
This seems to work perfect. We've tested it with all the RichView document templates we've created and with various data and all of our tables display and roll up the data without any problems so far.