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

Unable to access combo box in GridViewComboBoxColumn

0 Answers 17 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ha
Top achievements
Rank 1
Ha asked on 30 Nov 2011, 06:13 PM
Hi,

I use RadGridView in a xaml. The gridview has a column with checkbox, and another column with combobox (I use GridViewComboBoxColumn for this column). What I want to do is when the check box is checked, the combobox of the same row will be disabled (or readonly). In the Checked event of the checkbox, I try to get the combobox, but it always returns null. Could you tell me how to get to the combo box and disable it.

Here is part of my xaml:
<telerik:RadGridView ....>
    <telerik:RadGridView.Columns>
        ....
        <telerik:GridViewDataColumn Header="Manager" UniqueName="RoleId">
            <telerik:GridViewDataColumn.CellTemplate>
               <DataTemplate>
                    <CheckBox IsChecked="{Binding Path=RoleId, Converter={StaticResource RoleIdBooleanConverter}, Mode=TwoWay}"
                              x:Name="ManagerCheckBox" Checked="ManagerCheckBox_Checked"/>
               </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>

         <telerik:GridViewComboBoxColumn Header ="X Level" UniqueName="XLevel"  DataMemberBinding="{Binding Path=XLevel, 
              Mode=TwoWay}"
              ItemsSourceBinding="{Binding Source={StaticResource XLevelResource}}"  DisplayMemberPath="XInfo"      
              SelectedValueMemberPath="XItem" >
          </telerik:GridViewComboBoxColumn>
....

Here is my Checked event:
private void ManagerCheckBox_Checked(object sender, RoutedEventArgs e) {
     CheckBox cb = sender as CheckBox;
     if ( cb.IsChecked.HasValue && cb.IsChecked.Value ) {    
        var gvr = cb.ParentOfType<GridViewRow>(); // I get the row here
        var comboB = gvr.ChildrenOfType<GridViewComboBoxColumn>().Where(b=>b.UniqueName=="XLevel").FirstOrDefault();
        // comboB is always null here.
    
Thank you,

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Ha
Top achievements
Rank 1
Share this question
or