gpt4 book ai didi

c++ - 删除 Firemonkey TListView 中的项目会导致超出范围异常

转载 作者:行者123 更新时间:2023-11-28 06:08:49 27 4
gpt4 key购买 nike

我有一个包含多个项目的 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();
}

当我尝试删除项目时,抛出“参数超出范围”异常。但是,它不在 Delete 调用中,而是在此处的 System.Generics.Collections 中:

procedure TListHelper.CheckItemRange(AIndex: Integer);
begin
CheckItemRangeInline(AIndex); //this is the line that throws the exception
end;

我是否从我的 ListView 中不正确地删除了一个项目?或者是否有其他原因导致此问题?

最佳答案

您的代码是删除 ListView 中的项目的正确方法,因此一定有其他错误。作为确认,以下是 Embarcadero 的一些示例,这些示例显示了正在使用的这种技术:

此问题已在 C++ Builder 的新更新中得到纠正。我在东京和柏林亲自尝试过,可以确认它工作正常。

关于c++ - 删除 Firemonkey TListView 中的项目会导致超出范围异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31732864/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com