This is a migrated thread and some comments may be shown as answers.

Cell Read only property in DataGrid View

1 Answer 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
bhogavalli
Top achievements
Rank 1
bhogavalli asked on 16 Nov 2010, 01:14 PM
Hi Telerik Team,

        Is there any option to assign read only property to a particular cell in the Data grid view.
     I need to make some cells read only in a column to support some functionality. Please provide solution for he Query ASAP.


Regards
Sandeep.

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 16 Nov 2010, 01:55 PM
Hello,

There is no such property but you can use the CellInfo.Tag for this, which you can assign in DataBindingComplete event, like so:
void radGridView1_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
{
    foreach (var row in radGridView1.Rows)
    {
        if (row.Index % 2 == 0)
        {
            row.Cells[0].Tag = true;
        }
    }
}
 
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (e.Row.Cells[e.ColumnIndex].Tag != null && e.Row.Cells[e.ColumnIndex].Tag.Equals(true))
    {
        e.Cancel = true;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
Tags
GridView
Asked by
bhogavalli
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or