Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to: Disable Property Editors Based on a Business Rule

$
0
0

This example demonstrates how to hide and disable property editors via the Conditional Appearance module. The complete description is available in the How to: Disable Property Editors Based on a Business Rule help topic.

Question Comments

Added By: naresh vadala at: 5/13/2015 4:20:05 AM    

Team,

Can we achieve this without Appearance attribute, if yes please provide sample.

Thank you.
Regards,
Naresh Vadala.

Added By: Konstantin B (DevExpress) at: 5/13/2015 5:47:47 AM    Hi Naresh,

Yes, you can specify Appearance Rules in the Model Editor as it is demonstrated in the Declare Conditional Appearance Rules in the Application Model topic. If you want to avoid the use of the Conditional Appearance module at all, try the following Controller:

[C#]
usingDevExpress.ExpressApp;usingDevExpress.ExpressApp.Editors;// ...publicclassCustomizeContactAppearanceController:ObjectViewController<DetailView,Contact>{protectedoverridevoidOnActivated(){base.OnActivated();UpdateAppearance();ObjectSpace.ObjectChanged+=ObjectSpace_ObjectChanged;ObjectSpace.Committed+=ObjectSpace_Committed;View.SelectionChanged+=View_SelectionChanged;}protectedoverridevoidOnDeactivated(){ObjectSpace.ObjectChanged-=ObjectSpace_ObjectChanged;ObjectSpace.Committed-=ObjectSpace_Committed;View.SelectionChanged-=View_SelectionChanged;base.OnDeactivated();}voidObjectSpace_ObjectChanged(objectsender,ObjectChangedEventArgse){UpdateAppearance();}voidObjectSpace_Committed(objectsender,EventArgse){UpdateAppearance();}voidView_SelectionChanged(objectsender,EventArgse){UpdateAppearance();}privatevoidUpdateAppearance(){foreach(ViewItemiteminView.Items){if(item.Id=="SpouseName")UpdateSpouseNameVisibility(itemasIAppearanceVisibility);if(item.Id=="Address2")UpdateAddress2Visibility(itemasIAppearanceEnabled);}}privatevoidUpdateSpouseNameVisibility(IAppearanceVisibilityitem){if(!ViewCurrentObject.IsMarried)item.Visibility=ViewItemVisibility.Hide;elseitem.Visibility=ViewItemVisibility.Show;}privatevoidUpdateAddress2Visibility(IAppearanceEnableditem){item.Enabled=!string.IsNullOrEmpty(ViewCurrentObject.Address1);}}




Viewing all articles
Browse latest Browse all 7205

Trending Articles