如何禁用WPF Datagrid中的编辑单元格? [英] How can I disable editing cells in a WPF Datagrid?

查看:303
本文介绍了如何禁用WPF Datagrid中的编辑单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows Presentation Foundation中构建一个数据网格,我有一个问题。当用户双击数据网格中的单元格时,单元格将进入编辑模式。我想防止这个。相反,我希望用户能够选择完整的行 - 不要在其中编辑值。



如何让双击选择完整行,而不是将点击的单元格设置为编辑模式?

解决方案

WPF DataGrid 有一个 IsReadOnly 属性,您可以设置为 True 以确保用户无法编辑您的 DataGrid



您还可以根据需要为 DataGrid 中的各个列设置此值。


I'm constructing a datagrid in Windows Presentation Foundation, and I have a problem. When a user double-clicks on a cell in my datagrid, the cell goes into edit mode. I want to prevent that. Instead I want users to be able to select the full row - not edit values in it.

How can I make it so that double-clicks select the full row instead of putting the clicked-on cell in edit mode?

解决方案

The WPF DataGrid has an IsReadOnly property that you can set to True to ensure that users cannot edit your DataGrid's cells.

You can also set this value for individual columns in your DataGrid as needed.

这篇关于如何禁用WPF Datagrid中的编辑单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆