在Firemonkey TListView中删除项目会导致超出范围的异常
Deleting item in Firemonkey TListView causes out of range exception
我有一个TListView
与几个项目,其中每个项目有一个相应的"删除"按钮。TListView
具有以下按钮单击事件处理程序:
void __fastcall TSettingsCopyWizard_Fac::CopyToListViewButtonClick(TObject * const Sender,
TListViewItem * const AItem, TListItemSimpleControl * const AObject)
{
CopyToListView->BeginUpdate();
CopyToListView->Items->Delete(AItem->Index);
CopyToListView->EndUpdate();
}
当我尝试删除一个项时,抛出一个"Arguments out of range"异常。然而,它不在Delete
调用上,而是在System.Generics.Collections
中:
procedure TListHelper.CheckItemRange(AIndex: Integer);
begin
CheckItemRangeInline(AIndex); //this is the line that throws the exception
end;
从列表视图中删除项目是否不正确?还是有其他原因导致了这个问题?
您拥有的代码是在ListView中删除项的正确方法,因此一定有其他错误。作为确认,以下是来自Embarcadero的一些例子,展示了这种技术的使用:
- 东京柏林
这个问题在c++ Builder的新更新中得到纠正。我自己也在东京和柏林试过,可以确认效果很好。
相关文章:
- 关于:C++中异常对象的范围:为什么我没有得到副本?
- 为什么这个正则表达式C++在括号表达式中抛出无效范围异常?
- C++矢量超出范围异常
- 张量不会在超出范围索引时引发异常
- 如果一个对象是在本地创建的,并在C++中作为异常抛出,那么本地对象如何在其范围之外有效,即在 catch 块中?
- basic_string::替换的超出范围异常,而在范围内,正如调试相同参数的输出所证明的那样
- 当数字可能超出C++中特定数据类型的范围时如何处理异常?
- 程序崩溃,说向量不超出范围异常
- Windows 错误报告和超出范围的异常
- 对象在超出范围时是否被销毁,因为它们已引发异常.C++
- 从覆盖范围报告中删除自动生成的异常代码
- C++ 超出范围异常
- 为什么在 std::vector 中使用索引超出范围的运算符 [] 时没有出现异常?
- 为什么这会导致超出范围的异常
- 用于处理超出范围错误的异常类 - C++
- 当传递表示负值的十六进制时,C++stoll抛出超出范围的异常
- 字符串长度为10或更长的c++stol抛出范围外异常
- C++:如果抛出异常,那么超出范围的对象将被销毁
- 给定范围内的完美平方:循环执行异常
- 通过引用捕获(使用 catch)时异常对象的范围