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

[Solved] Disable column in code behind

3 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Satya
Top achievements
Rank 1
Satya asked on 18 Jul 2011, 05:08 PM
Hi,

How to disable a column from code behind ?
Can some one please help me ?

Thanks
Sayap

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 18 Jul 2011, 05:16 PM
Hello Satya,

You may create a Style targeting GridViewCell and set it to the column you require:

XAML:
<UserControl.Resources>
    <Style x:Key="MyCellStyle" TargetType="telerik:GridViewCell">
        <Setter Property="IsEnabled" Value="False" />
    </Style>
</UserControl.Resources>
 
C#:
(this.clubsGrid.Columns[0] as GridViewDataColumn).CellStyle = (Style)this.Resources["MyCellStyle"];

 

Kind regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Satya
Top achievements
Rank 1
answered on 18 Jul 2011, 06:15 PM
Thank you for the response.

It is disabling the column. It is not disabling the column header of that column,its column header has a check box.
I wanted to disable the column header also. How Can I disable the column header.

Thank you.
Sayap


0
Satya
Top achievements
Rank 1
answered on 18 Jul 2011, 07:51 PM
Hi Maya,

There is one issue I noticed while applying the style that you have suggested.

My grid has 200 rows only 20 rows are visible with in the viewable area, rest of them are visible when I scroll down.
The issue is I am trying to disable/Eable the column based on a user action i.e click of a checkBox , this check box is outside of the of the grid.

When the user checks the checkbox I am Enabling the column. When the user Unchecks the checkbox I am disabling the column.
But the thing is unless and until I scroll down and scroll up the scroll bar in the gird the column is not enabling or disabling.

Can you please advise?. Thanks for your help

Thanks & Regards
Sayap



Tags
GridView
Asked by
Satya
Top achievements
Rank 1
Answers by
Maya
Telerik team
Satya
Top achievements
Rank 1
Share this question
or