Always Enabled in DataForm

6 posts, 0 answers
  1. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 10 Jun 2010 Link to this post

    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!

  2. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 10 Jun 2010 Link to this post

    Hi Louis,

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

    Best regards,
    Seree W.
  3. DevCraft banner
  4. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 11 Jun 2010 Link to this post

    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;

     

    }

  5. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 11 Jun 2010 Link to this post

    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.
  6. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 11 Jun 2010 Link to this post

    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?

  7. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 11 Jun 2010 Link to this post

    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.
Back to Top
DevCraft banner