[英]Select all in ListBox by clicking a Button
I would like to highlight all content of a ListBox by a press of a button, but it doesn't work.我想通过按一下按钮突出显示 ListBox 的所有内容,但它不起作用。
private void selectAll_Click(object sender, RoutedEventArgs e)
{
resultbox.Select();
}
I also wanted to have a "label" to count how many rows has the same ListBox.我还想有一个“标签”来计算有多少行具有相同的 ListBox。 What should I do?
我该怎么办?
You can use on button click:您可以在按钮单击时使用:
for (int i = 0; i < myListBox.Items.Count;i++)
{
myListBox.SetSelected(i, true);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.