Clear datagrid values in wpf

后端 未结 7 1449
粉色の甜心
粉色の甜心 2021-01-11 19:14

I need to flush my datagrid everytime when a treeviewitem is clicked. My code is given below.

private void treeView1_SelectedItemCh         


        
7条回答
  •  再見小時候
    2021-01-11 19:59

    You may consider using ObservableCollection<> class rather than IEnumerable<>.

    ObservableCollection users = new ObservableCollection();
    dataGrid1.ItemsSource = users;
    

    You can clear the datagrid by using the below code.

    users.Clear();
    

提交回复
热议问题