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

GridView CheckBoxColumn

3 Answers 254 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sarag
Top achievements
Rank 1
sarag asked on 17 Feb 2011, 04:47 PM
Hi

I am using Q3 2010, Blend 4, VS 2010. i am generating Columns dynamically using GridviewCheckboxColumn  my questions are

1. i am using style to align the checkbox at the center of the Column., its working perfectly fine, but the problem is when i am trying 
    to edit the checkbox moves to the left of the bound column.

2. I need to use two clicks to edit the checkbox, but i am setting the checbox

        EditTriggers = 

 

GridViewEditTriggers.CellClick;

 

         AutoSelectOnEdit = true;
   i need to do two clicks ,

3. I need to set the width and height of the gridviewcheckbox column when i set width =50, height =50, in
   edit mode it is going back to the defulat width and height

please check the attached file

 

 

<Style TargetType="telerik:GridViewCheckBox">
           <Setter Property="HorizontalAlignment" Value="Center"/>
       </Style>
thanks
sarag

 

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 17 Feb 2011, 05:39 PM
Hi Sarag,

You may create a style targeted at GridViewCell and set its HorizontalContentAlignment to Center as it is shown at the snippet below:

 <Window.Resources>
     <Style x:Key="s1" TargetType="telerik:GridViewCell">
           <Setter Property="HorizontalContentAlignment" Value="Center"/> 
       </Style>
</Window.Resources>
 <Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView Width="600" AutoGenerateColumns="False" Height="500"  ShowGroupFooters="True"  ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn CellStyle="{StaticResource s1}" Header="Sms" DataMemberBinding="{Binding Married}"/>
                <telerik:GridViewCheckBoxColumn CellStyle="{StaticResource s1}" Header="Something" DataMemberBinding="{Binding Married}"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>




 Regards,
Vanya Pavlova
the Telerik team
0
sarag
Top achievements
Rank 1
answered on 17 Feb 2011, 05:43 PM
How can i write these using chsarp code. and how can i acheive below one.
2. I need to use two clicks to edit the checkbox, but i am setting the checbox
EditTriggers = GridViewEditTriggers.CellClick;
AutoSelectOnEdit = true;
i need to do two clicks ,
3. I need to set the width and height of the gridviewcheckbox column when i set width =50, height =50,
    in edit mode it is going back to the defulat width and height
0
Vanya Pavlova
Telerik team
answered on 18 Feb 2011, 12:30 PM
Hi Sarag,

 When you dynamically create columns in RadGridView, you need to refer to the appropriate CellStyle. It resides in a Resource collection. If you need to change the style of GridViewCheckBox, you need to edit its template and apply the desired changes. When a GridViewCheckBox column goes into edit mode, a standrad CheckBox appears. If you need to synchronize these styles, you also need to edit the template of CheckBox control and change its size.  In addition to this you may take a look at the following forum thread "GridViewCheckBox style ".


You may find attached sample project that demonstrates the approaches above.


All the best,
Vanya Pavlova
the Telerik team
Tags
GridView
Asked by
sarag
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
sarag
Top achievements
Rank 1
Share this question
or