C# 如何更改“listView1.FocusedItem.Index”的值?
我正在Windows Mobile中向listView添加和删除项目。 我使用的是listView1\u SelectedIndexChanged函数,仅当我按下与上次按下不同的行索引时才会调用该函数。 是否有方法更改listView1.FocusedItem.Index变量并为其指定一个无效值或其他值,以便在每次按下列表中的某个项时调用该函数,而不仅仅是在该项是新索引时?C# 如何更改“listView1.FocusedItem.Index”的值?,c#,windows-mobile,C#,Windows Mobile,我正在Windows Mobile中向listView添加和删除项目。 我使用的是listView1\u SelectedIndexChanged函数,仅当我按下与上次按下不同的行索引时才会调用该函数。 是否有方法更改listView1.FocusedItem.Index变量并为其指定一个无效值或其他值,以便在每次按下列表中的某个项时调用该函数,而不仅仅是在该项是新索引时? 谢谢 您使用的是什么版本的Windows Mobile?并非所有版本都支持相同的东西 您实际上只能从控件中读取 哪一个更适
谢谢 您使用的是什么版本的Windows Mobile?并非所有版本都支持相同的东西 您实际上只能从控件中读取 哪一个更适合你的需要,按“的”或“的”行事 [注:以上所有链接均包含示例代码]
ListView listView1;
private void init_listView1() {
listView1.ItemActivate += new EventHandler(listView_Focus);
listView1.GotFocus += new EventHandler(listView_Focus);
}
private void listView_Focus(object sender, EventArgs e) {
int index = -1;
if ((listView1.SelectedIndices != null) && (0 < listView1.SelectedIndices.Count)) {
index = listView1.SelectedIndices[0];
ListViewItem item = listView1.Items[index];
} else {
if (0 < listView1.Items.Count) {
index = 0;
}
}
if (-1 < index) {
listView1.Items[index].Focused = true;
}
}