New to Telerik UI for WPF? Download free 30-day trial

Read Only Rows and Cells

This article shows how to control which rows or cells to be read only.

Before Q2 2010 SP2, the RadGridView had only one property to control the read-only state - IsReadOnly, which either enables or disables editing at gridview level. The only solution was to subscribe to the BeginningEdit event and cancel it if you do not want to edit a particular cell.

In Q2 2010 SP2, we added a new property - IsReadOnlyBinding at a gridview and a column level. You can bind it to a boolean property of your business object. Here is how it works depending on where it is set:

IsReadOnlyBinding at RadGridView level [Read Only Rows]

When you set IsReadOnlyBinding property of RadGridView to True - the full row becomes read only when the underlying property is True.

Example 1: Binding IsReadOnlyBinding at RadGridView level.

<telerik:RadGridView x:Name="radGridView" IsReadOnlyBinding="{Binding IsActive}" /> 

IsReadOnlyBinding at column level [Read Only Cells]

When you set the IsReadOnlyBinding property of the GridViewDataColumn - only the cells of that column are affected.

Example 2: Binding IsReadOnlyBinding at column level.

<telerik:RadGridView> 
    <telerik:RadGridView.Columns> 
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Age}"  
                    IsReadOnlyBinding="{Binding IsActive}" /> 
        <!--...--> 
    </telerik:RadGridView.Columns> 
</telerik:RadGridView> 

In both cases the property to which IsReadOnlyBinding is bound is exposed by the business object. In the example above "IsActive" as well as "Age" are properties of one and the same data item.

You can download a runnable project illustrating the different setups from our online SDK repository here.

You can also check the SDK Samples Browser that provides a more convenient approach in exploring and executing the examples in the Telerik XAML SDK repository.

In this article