Why is IsReadOnly read only for a DataGridCell???

May 25, 2009 at 9:23 PM

error MC3080: The Property Setter 'IsReadOnly' cannot be set because it does not have an accessible set accessor. Line 204 Position 45.

I would like t set each individual cell read only rather than an entire column.  Is this an oversight by Microsoft or am I the only person in the entire world who would like to set this property?  Anyone know if Microsoft is planning to make this writable?

 

 

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Style TargetType="{x:Type dg:DataGridCell}" BasedOn="{StaticResource CellStyle}"><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Setter Property="IsTabStop" Value="{Binding Path=[Inc].Enabled}"/><font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

 

<Setter Property="IsReadOnly" Value="True"/>

</Style>

<font size="1">

Tab Stop is writable, but not IsReadOnly.

</font>

 

Coordinator
May 26, 2009 at 12:38 PM

What is your scenario?

May 26, 2009 at 2:24 PM

Well I have a SS where I want certain cells read only based on business logic.  For instance, if I have a specific record, maybe a cell is read only for another record it is editable.  Thus, I can’t set the readonly on the entire column but I want to put it on a specific cell.  I don’t want to use enable property which is available on individual cells (I prefer to use the readonly rather than disable property for edit controls because I find the readonly property to be superior => for instance a read only cell might be a calculated value and you might want to copy the value to another application, an disabled cell is not copiable).

 

Additional logic might be the cell is editable and then when other data on the row changes, it becomes enabled.

 

For instance, lets say the columns are:

 

Items – combo box

Weight – edit control

Volume – edit control

 

If item is say water, volume is editable and weight is read only

If item is say oranges, volume is read only and weight is editable

 

I don’t know why the read only flag is read only so I can’t set the value on individual cells based on business logic.

Coordinator
May 26, 2009 at 8:57 PM

Currently there's no support for setting DataGridCell.IsReadOnly.  One way to work around this issue is to update the edit mode of the cell based on your business logic.