[英]WPF DataGrid - make column readonly via c#
I am trying to turn off the isReadOnly property of a WPF Datagrid cell via c#. 我试图通过c#关闭WPF Datagrid单元格的isReadOnly属性。 I need to do this once a user clicks on a row. 一旦用户点击一行,我就需要这样做。
I have this so far 到目前为止我有这个
private void dgProductItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
DataGrid dg = sender as DataGrid;
if (dg != null)
{
DataGridRow dgr = (DataGridRow)(dg.ItemContainerGenerator.ContainerFromIndex(dg.SelectedIndex));
}
}
But how do I get down to the cell level via the 但是我如何通过网络进入细胞水平
DataGridRow DataGridRow
So finally I am looking for cell.ISReadOnly = false/true; 所以最后我要找cell.ISReadOnly = false / true;
Cheers 干杯
If you want to work on the DataGridCell
object, you are going to need a little bit more code than expected 如果要处理DataGridCell
对象,则需要比预期更多的代码
Check the answer here and use the TryTofindGridCell
method to retrieve the DataGridCell
object and then set its IsreadOnly
property 在这里检查答案并使用TryTofindGridCell
方法检索DataGridCell
对象,然后设置其IsreadOnly
属性
Alternatively you can also check the solution described here to retrieve DataGridRow
s / DataGridCell
或者,您也可以检查此处描述的解决方案以检索DataGridRow
s / DataGridCell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.