添加选择的所有快捷键(Ctrl + A键)为.NET列表视图? [英] Adding a select all shortcut (Ctrl + A) to a .net listview?
问题描述
喜欢的科目说,我有一个列表视图,我想补充的<大骨节病>控制骨节病> + <大骨节病> A 骨节病>选择所有的快捷方式了。我的第一个问题是,我无法弄清楚如何以编程方式选择列表视图的所有项目。现在看来似乎应该是比较容易的,比如 ListView.SelectAll()
或 ListView.Items.SelectAll()
,但是,这并不出现这种情况。我的下一个问题是如何定义的的ListView
快捷键。难道我这样做是在的KeyUp
事件,但你会怎么检查两个presses一次?或者是您设置的属性?
Like the subject says I have a listview, and I wanted to add the Ctrl + A select all shortcut to it. My first problem is that I can't figure out how to programmatically select all items in a listview. It seems like it should be relatively easy, like ListView.SelectAll()
or ListView.Items.SelectAll()
, but that doesn't appear to be the case. My next problem is how to define the keyboard shortcut for the ListView
. Do I do it in a KeyUp
event, but then how would you check two presses at once? Or is it a property that you set?
任何帮助将是巨大的。
推荐答案
您可以像这样同时完成:
You could accomplish both with something like this:
private void listView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.A && e.Control)
{
listView1.MultiSelect = true;
foreach (ListViewItem item in listView1.Items)
{
item.Selected = true;
}
}
}
这篇关于添加选择的所有快捷键(Ctrl + A键)为.NET列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!