简体   繁体   中英

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.

  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. What should I do?

You can use on button click:

 for (int i = 0; i < myListBox.Items.Count;i++)
 {
      myListBox.SetSelected(i, true);
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM