Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF DataGrid: Make cells readonly

Tags:

wpf

datagrid

I use the following DataGrid

<DataGrid Grid.Row="1" Grid.Column="1" Name="Grid" ItemsSource="{Binding}"  AutoGenerateColumns="False" >             <DataGrid.Columns>                 <DataGridTextColumn Header="Name" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn>                 <DataGridTextColumn Header="OldValue" Width="100" Binding="{Binding Path=OldValue}"></DataGridTextColumn>                 <DataGridTextColumn Header="NewValue" Width="100*" Binding="{Binding Path=NewValue}"></DataGridTextColumn>             </DataGrid.Columns>         </DataGrid> 

How can I make the cells readonly?

like image 776
crauscher Avatar asked Mar 23 '10 19:03

crauscher


People also ask

How to make DataGrid ReadOnly in wpf?

You can easily use IsReadOnly property on the DataGrid to make it entirely read only. or use IsReadOnly per Column basis to make them read only. The WPF DataGrid has an IsReadOnly property that you can set to True to ensure that users cannot edit your DataGrid 's cells.

How do I make a DataGrid read only?

To make individual columns or cells read-only, set the DataGridColumn. IsReadOnly or DataGridCell. IsReadOnly properties. If a conflict exists between the settings at the DataGrid, column, or cell levels, a value of true takes precedence over a value of false .

How do I make a datagridview column read-only?

In the DataGridViewcontrol, the column ReadOnlyproperty value determines whether users can edit cells in that column. For information about how to make the control entirely read-only, see How to: Prevent Row Addition and Deletion in the Windows Forms DataGridView Control.

How to make a grid cell read-only in grid control?

In v 19.2 and newer versions, Grid Control supports the Disabled Cell Behavior that allows you to disable individual grid cells and customize their appearance with ease. To make a grid cell read-only, handle the ShowingEditor event and set the e.Cancel parameter to true.

Can I edit cells in a column in the datagridview control?

In this article Not all data is meant for editing. In the DataGridViewcontrol, the column ReadOnlyproperty value determines whether users can edit cells in that column. For information about how to make the control entirely read-only, see How to: Prevent Row Addition and Deletion in the Windows Forms DataGridView Control.

Can I make the DataGrid readyonly at cell level?

I understand you can make the whole DataGrid or a whole column readyonly (IsReadOnly = true). However, at cell level this property is ready only. But I do need this level of granularity.


1 Answers

Set DataGrid's IsReadOnly property to true.

<DataGrid Grid.Row="1" Grid.Column="1" Name="Grid" ItemsSource="{Binding}"     IsReadOnly="True" AutoGenerateColumns="False" > 
like image 191
Taylor Leese Avatar answered Oct 10 '22 18:10

Taylor Leese