【发布时间】:2012-02-21 20:30:29
【问题描述】:
我在 .NET 中的表单上有一个 ListView。
在隐藏表单之前,SelectedIncides 存在且有效:
void buttonOK_click()
{
Assert(listView.SelectedIndices.Count > 0);
DialogResult = DialogResult.OK;
}
但模态形式返回后:
form1.ShowDialog();
Assert(form1.listView.SelectedIndices.Count > 0);
第二个断言失败。
一旦列表视图所在的表单被隐藏(尽管没有销毁/处置/释放),如何读取ListView 的SelectedIndices?
【问题讨论】:
-
SelectedIndices集合不能因表单已关闭而更改。我建议您检查可能被触发并取消选择项目的其他事件。ShowModal你的意思是ShowDialog- 显示一个模态对话框? -
另一位用户在选择索引时遇到问题。 (stackoverflow.com/questions/304844/…)