Tôi cần xóa số datagrid
mỗi lần khi nhấp vào treeviewitem
. Mã của tôi được đưa ra dưới đây.Xóa các giá trị dữ liệu trong wpf
private void treeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
this.dataGrid1.Columns.Clear();
this.dataGrid1.ItemsSource= null;
String path =this.treeView1.SelectedItem;
if (!File.Exists(path))
MessageBox.Show("Not Found");
else
{
ob.provider(path);
// String data = @"C:\logs.xml";
string data = path;
objref.functionality(data);
this.dataGrid1.ItemsSource = objref.Result;
}
}
Nhưng mỗi khi tôi nhấp vào dữ liệu mục treeview không được xóa - nó được nối với dữ liệu đến. Tôi đã sử dụng cả hai dataGrid1.Columns.Clear()
và dataGrid.ItemSource= null;
Tôi có thể làm điều này bằng cách nào?
Am với ItemsSource. tôi đã đặt nó thành null. Đó là câu hỏi của tôi. Nhưng dữ liệu của tôi vẫn chưa được xóa .. – BinaryMee
Đó có phải là vị trí duy nhất bạn đang điền vào nó không? – Rhexis
thử làm mới nó: dataGrid.Items.Refresh(); – Rhexis