Delete Table Rows causes List index out of bounds error
Posted: Mon Nov 04, 2013 10:49 pm
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.
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.