[英]C# Error trying to edit item of DataGrid
So when i try to edit or add or delete from a DataGrid in WPF is giving me 'EditItem' is not allowed for this view. 因此,当我尝试在WPF中编辑或添加或删除DataGrid时,我认为此视图不允许使用'EditItem'。
providersDataGrid.CanUserAddRows = true;
providersDataGrid.CanUserDeleteRows = true;
providersTableAdapter adapter = new providersTableAdapter();
adapter.Fill(ds.providers);
providersDataGrid.ItemsSource = adapter.GetData().Rows;
i have activated Autogenerate Columns. 我已激活自动生成列。
So how i can do it? 那么我怎么做呢? thanks for your answer. 感谢您的回答。
Try to set the ItemsSource
property to the actual DataView
: 尝试将ItemsSource
属性设置为实际的DataView
:
providersDataGrid.ItemsSource = ds.providers.DefaultView;
or 要么
providersDataGrid.ItemsSource = adapter.GetData();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.