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

[Solved] Setting Unbound CheckBox.IsChecked

1 Answer 126 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.
suth
Top achievements
Rank 1
suth asked on 18 Sep 2009, 04:58 PM
Wondering how to set cbReached.IsChecked = true when the CheckBox is in an unbound column.  I have the row index number, but it is not in the Items collection and I am undable to find the control.
Thanks.

<telerikGridView:GridViewDataColumn UniqueName="Reached" >

 

    <telerikGridView:GridViewDataColumn.CellTemplate>

 

        <DataTemplate>

 

            <CheckBox x:Name="cbReached"></CheckBox>

 

        </DataTemplate

 

    </telerikGridView:GridViewDataColumn.CellTemplate>

 

 

 

</telerikGridView:GridViewDataColumn>

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 22 Sep 2009, 08:34 AM
Hello suth,

Just subscribe to the Loaded event of the CheckBox:

<telerik:GridViewColumn.CellTemplate> 
    <DataTemplate> 
        <CheckBox x:Name="cbReached"   
                  Loaded="cbReached_Loaded"></CheckBox> 
    </DataTemplate> 
</telerik:GridViewColumn.CellTemplate> 

... And in the event handler determine if the column is unbound:

// required namespace: Telerik.Windows.Controls  
private void cbReached_Loaded(object sender, RoutedEventArgs e)  
{  
    CheckBox checkBox = sender as CheckBox;  
    GridViewCell parentCell = checkBox.ParentOfType<GridViewCell>();  
 
    if (parentCell == null)  
        return;  
 
    GridViewDataColumn column = parentCell.Column as GridViewDataColumn;  
 
    if (column == null || column.DataMemberBinding == null)  
        checkBox.IsChecked = true;  

Hope this helps.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
suth
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or