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

Always Enabled in DataForm

5 Answers 103 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Louis Bouchard
Top achievements
Rank 1
Louis Bouchard asked on 11 Jun 2010, 02:42 AM
Hello,

My RadComboBox is always enabled in my DataForm even if I'm not in EditMode. 

I try this w/o success :

1) Set by default IsEnabled="false" my RadComboBox
2) In the BeginningEdit event : ((RadComboBox)DataFormfiche.FindNameInContent("CategoriesComboBox")).IsEnabled = true;    
3) In the EditEnding event :  ((RadComboBox)DataFormfiche.FindNameInContent("CategoriesComboBox")).IsEnabled = false; 

Always disabled!

5 Answers, 1 is accepted

Sort by
0
Seree
Top achievements
Rank 2
answered on 11 Jun 2010, 04:26 AM
Hi Louis,

Would you mine sharing your XAML and code-behind here so we can help you quicker? :)

Best regards,
Seree W.
0
Louis Bouchard
Top achievements
Rank 1
answered on 11 Jun 2010, 05:28 AM

A big thank you for your help Seree :

XAML File :

 

<

 

toolkit:DataForm Name="DataFormfiche" EditEnding="DataFormfiche_EditEnding" BeginningEdit="DataFormfiche_BeginningEdit" Background="Beige" Width="1024" CommandButtonsVisibility="Add, Cancel, Commit, Delete, Edit, Navigation" ItemsSource= "{Binding Data, ElementName=ficheDomainDataSource}" AutoGenerateFields="False" AutoCommit="False" AutoEdit="False" AddingNewItem="DataFormfiche_AddingNewItem" ContentLoaded="DataFormfiche_ContentLoaded" Loaded="DataFormfiche_Loaded" EditEnded="DataFormfiche_EditEnded">

 

 

 

 

...

 

 

<toolkit:DataField Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left">

 

 

 

 

 

 

<telerik:RadComboBox Name="NoCategorieComboBox" IsEnabled="False"  SelectedValue="{Binding NoCategorieEspaceClos, Mode=TwoWay}" SelectedValuePath="NoCategorie" Width="240" Height="25" ItemsSource="{Binding Source={StaticResource categoriesespacesclosDomainDataSource}, Path=Data}" DisplayMemberPath="DescriptionCategorie_fr" />

 

 

 

 

 

 

 

</toolkit:DataField>

 

 

 

 

...

 

 

</DataTemplate>

 

</

 

toolkit:DataForm.EditTemplate>

 

</

 

toolkit:DataForm>

XAML.CS File

 

 

private void DataFormfiche_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e)

 

{

((

RadComboBox)DataFormfiche.FindNameInContent("NoCategorieComboBox")).IsEnabled = true;

 

}

 

private void DataFormfiche_EditEnding(object sender, DataFormEditEndingEventArgs e)

 

{

((

RadComboBox)DataFormfiche.FindNameInContent("NoCategorieComboBox")).IsEnabled = false;

 

}

0
Seree
Top achievements
Rank 2
answered on 11 Jun 2010, 05:51 AM
Hi Louis,

Please try setting IsEnabled by using ContentLoaded instead of BeginningEdit/EditEnding.

void FormDetails_ContentLoaded(object sender, DataFormContentLoadEventArgs e) 
        { 
            var lookup = (FormDetails.FindNameInContent("ComboLookup") as RadComboBox);             
            if (e.Mode == DataFormMode.ReadOnly) 
            { 
                lookup.IsEnabled = false
            } 
            else 
            { 
                lookup.IsEnabled = true
            } 
        } 


Hope this help.

Best regards,
Seree W.
0
Louis Bouchard
Top achievements
Rank 1
answered on 11 Jun 2010, 06:16 PM
Hello Seree,

Thank you for your code.  I try it and the code excute fine but the control stay in the same state (enabled).

The DataForm need to be refresh or something like this?

0
Louis Bouchard
Top achievements
Rank 1
answered on 12 Jun 2010, 01:34 AM
It's working now.  Thank you for the information Seree, you help me to find the final solution.  THe only difference, I use direct reference to the RadComboBox.

            //var lookup = (DataFormficheespacesclos.FindNameInContent("ComboBoxQuantite") as RadComboBox);
            if (e.Mode == DataFormMode.ReadOnly)
            {
                //lookup.IsEnabled = false;
                ((RadComboBox)DataFormficheespacesclos.FindNameInContent("NoCategorieEspaceClosComboBox")).IsEnabled = false;
            }
            else
            {
                ((RadComboBox)DataFormficheespacesclos.FindNameInContent("NoCategorieEspaceClosComboBox")).IsEnabled = true;
                //lookup.IsEnabled = true;
            } 

Have nice day.
Tags
ComboBox
Asked by
Louis Bouchard
Top achievements
Rank 1
Answers by
Seree
Top achievements
Rank 2
Louis Bouchard
Top achievements
Rank 1
Share this question
or