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

Iterate through the row cells in telerik grid view

1 Answer 274 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sakshi
Top achievements
Rank 1
Sakshi asked on 17 Jun 2009, 04:49 AM
Hi All,


I am using a telerik grid view in a windows application being devloped in C# SCSF framework 3.5 .

I have the following columns in the grid

SN: Name: Desc: Read Allowed:Write Allowed

Read allowed and write allowed columns are check boxes.

When the grid is bound with a collection the check boxes of that particular row needs to be disabled if the collection property is false in the collection.
If the collection property is true then the check box in the particular row is enabled.

So rows may have enabled or disabled checkboxes based on the collection result returned after a search.

Can anyone help me as to how I can do this for all the rows shown in the grid at runtime.

This is easily possible in web as it has the RowDataBound and ItemDataBound events which can allow to enable disable cells in all rows

How do we achieve this in the windows forms...

Please help ..thanks in advance.

Regards,
Sakshi

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 19 Jun 2009, 01:02 PM
Hello Sakshi,

Thank you for writing

You can enable and disable cell in the CellFormatting event. Please, review the code-block below:
 
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)  
{  
    if (e.CellElement.ColumnIndex == 0)  //Column[0] is check box column thay we want to enable/disable  
    {  
        object value = ((GridCheckBoxCellElement)e.CellElement).Value;  
        if (!(value is DBNull) && (bool)value)  
        {  
            e.CellElement.Enabled = false;  
        }  
        else 
        {  
            e.CellElement.Enabled = true;  
        }  
    }  

Hope this helps. Do not hesitate to contact me again if you have other questions.

Kind regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Sakshi
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or