开发者

ListView Expander issue in wpf

开发者 https://www.devze.com 2023-03-28 15:44 出处:网络
I am using a checkbox on expander.I want, when I check that checkbox ,it will select all rows of list view those开发者_运维知识库 are coming under that expander.set the listview\'s selectionmode to Mu

I am using a checkbox on expander. I want, when I check that checkbox ,it will select all rows of list view those开发者_运维知识库 are coming under that expander.


set the listview's selectionmode to Multiple' or 'Extended and on the CheckBox_Checked event you can write the code to select the rows of listview

private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
    listview1.SelectAll();
}


Try this inside your checkbox_click events handler:

 listView1.BeginUpdate(); 
 foreach (ListViewItem i in listView1.Items)
 {
     i.Selected = true;
 }

 listView1.EndUpdate();

Which gives you a bit more flexibility.

0

精彩评论

暂无评论...
验证码 换一张
取 消