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

Enable/Disable a cell in gridview

4 Answers 470 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nitin Vikraman
Top achievements
Rank 1
Nitin Vikraman asked on 26 Apr 2010, 01:07 PM

Hi,

    is it possible to enable or disable a specific cell in Gridview. i am using Winforms Q1 2010 SP1 version. 

Regards,

Nitin

4 Answers, 1 is accepted

Sort by
0
Alcatraz
Top achievements
Rank 1
answered on 27 Apr 2010, 10:40 AM
hi Nitin,

Jus use the cellformatting event of that grid, identify the column and then set the enabled property of the cell to false.

like

private

 

void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)

 

{

 

 

    if (e.CellElement.ColumnInfo.HeaderText == "Type")

 

        {

 

            e.CellElement.Enabled =

false;

 

        }

 }

Hope this helps

Cheers
Kris

 

0
Accepted
Jack
Telerik team
answered on 27 Apr 2010, 11:14 AM
Hi Nitin Vikraman,

You should handle the CellBeginEdit event and cancel it to prevent a cell from being edited. Or, you can make the cell look disabled by setting its Enabled property to false when handling the CellFormatting event. We plan to add a property which indicates whether a cell is read only in one of our upcoming releases. 
 
Regards,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kristoffer
Top achievements
Rank 1
answered on 01 Nov 2013, 08:48 AM
CellElement still has no ReadOnly property? I don't understand why this isn't supported. It makes perfect sense to:

1) Allow editing "new row" column X value.
2) Disallow editing existing row's column X value.

A ReadOnly property of the cell would make life easier.
0
Stefan
Telerik team
answered on 05 Nov 2013, 09:47 AM
Hello,

This can easily be achieved with the CellBeginEdit event as well. For the time being we do not have a ReadOnly property of the CellElement. If there is demand for such, we will consider adding it in a future release:
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (!(e.Row is GridViewNewRowInfo) || !(e.Column.Name == "ColumnX"))
    {
        e.Cancel = true;  
    }
}

I hope this helps.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Nitin Vikraman
Top achievements
Rank 1
Answers by
Alcatraz
Top achievements
Rank 1
Jack
Telerik team
Kristoffer
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or