[英]DataGrid empty row by default (and always)
Good day! 美好的一天!
I try to make DataGrid with empty row by default and if user delete all rows- datagrid shoud add e new empty row. 我尝试使DataGrid默认为空行,如果用户删除所有行,则datagrid应该添加新的空行。
I try to do this: 我尝试这样做:
<DataGrid AutoGenerateColumns="False" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
Name="dg1"
ItemsSource="{Binding Path=RowColl}"
CanUserAddRows="True"
CanUserDeleteRows="True"
IsEnabled="True"
IsReadOnly="False"
> ...</DataGrid>
At *.xaml.cs: 在* .xaml.cs中:
RowColl = new ObservableCollection<Row>();
dg1.ItemsSource = RowColl;
But no empty row .. 但是没有空行..
Please, tell me how to get empty row by default and get always 1 row as empty. 请告诉我默认情况下如何获取空行并始终获取1行为空。 Thank you! 谢谢!
Use this 用这个
myDataGridView.AllowUserToAddRows = true;
It will display empty row at the end of datagrid view. 它将在数据网格视图的末尾显示空行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.