简体   繁体   English

WPF DataGrid EditItem异常

[英]WPF DataGrid EditItem exception

I have a TabControl and add TabItem on TabControl with DataGrid . 我有一个TabControl并使用DataGridTabControl上添加TabItem But if I double click on range crashes: 但是,如果我双击范围崩溃:

"EditItem" is not allowed for this view. 此视图不允许使用“ EditItem”。

                    System.Windows.Controls.DataGrid dataGrid = new System.Windows.Controls.DataGrid();
 DataGridTextColumn textColumn = new DataGridTextColumn();
                    textColumn.Header = "ID";
                    textColumn.Binding = new Binding("ID");
                    dataGrid.Columns.Add(textColumn);
                    item.Content = dataGrid;
                    tabControl1.Items.Add(item);

When add Item: 添加项目时:

list_datagrid[tabControl1.SelectedIndex].Items.Add(.list_item[tabControl1.SelectedIndex][i]);

Please tell me how to remove the error. 请告诉我如何清除错误。

Set the ItemsSource of the DataGrid to the collection that DataGrid can use to generate the view that implements IEditableCollectionView . DataGridItemsSource设置为DataGrid可用于生成实现IEditableCollectionView的视图的集合。 This interface has function EditItem() which let the editing happen. 该接口具有EditItem()函数,可以进行编辑。

I have answered the similar question here WPF datagrid "EditItem is not allowed for this view" exception 我在这里回答了类似的问题WPF datagrid“此视图不允许使用EditItem”异常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WPF 数据网格“此视图不允许编辑项”异常 - WPF datagrid "EditItem is not allowed for this view" exception 绑定到 WPF DataGrid 时,此视图不允许 DataGrid 版本“EditItem” - DataGrid edition 'EditItem' is not allowed for this view` when bound to a WPF DataGrid 在WPF中将ExpandoObject用作datagrid的行时,“此视图不允许使用&#39;EditItem&#39; - “'EditItem' is not allowed for this view” while I am using ExpandoObject as the row of datagrid in WPF 包装的 ObservableCollection<t> 绑定到 WPF DataGrid 时,此视图不允许抛出“EditItem”</t> - Wrapped ObservableCollection<T> throwing `'EditItem' is not allowed for this view` when bound to a WPF DataGrid WPF datagrid IsReadOnly异常 - WPF datagrid IsReadOnly exception 如果使用VirtualStackPanel,则WPF DataGrid中的异常 - Exception in WPF DataGrid if VirtualStackPanel is used 样式化DataGrid行WPF异常 - Styling DataGrid rows WPF exception WPF将项添加到绑定到observablecollection异常的datagrid - WPF add item to datagrid bound to observablecollection exception WPF DataGrid排序在添加项目时引发异常 - WPF DataGrid Sorting Throws exception on Item adding 该视图不允许使用“ EditItem”。 尝试在DataGrid中编辑项目时 - ''EditItem' is not allowed for this view.' when trying to edit a item in the DataGrid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM