Highlight List View Objects highlight the list view object

In this lesson, you will learn how to format data that satisfies the specified criteria. For this purpose, the Conditional Appearance module will be added to the application. You will highlight the DemoTask objects whose Status property is not set to Completed. In addition, you will highlight the Priority property when it contains the High value.

In this lesson, you will learn how to format the data specified conditions are met. For this purpose, the module is added to the conditions for the appearance of the application. You highlighted its Status property is not set to "complete" the demo task object. Further, when "the Priority" attribute contains the "high" value, the attribute highlighted.

 

  • Add the Conditional Appearance module to your MySolution.Module project. For this purpose, double-click the Module.cs (Module.vb) file, located in the MySolution.Module project. The Module Designer will be invoked. In the Toolbox, navigate to the DX.19.2: XAF Modules tab, and drag the ConditionalAppearanceModule item from this tab to the Designer's Required Modules section, as shown below.
  • Add the module to the conditions for the appearance of MySolution. Module project. To do this, double-located MySolution.module project Module.cs (Module.vb) files. The calling module designer. In the toolbox, navigate to DX.19.2: XAF module tab, and the appearance of the module entry conditions this tab drag "designer module required" section, below.

Tutorial_EM_Lesson_5_1

  • Rebuild your solution after you have made changes in the Module Designer.
  • To declare a conditional appearance rule for the DemoTask class, apply the AppearanceAttribute attribute to this class. As the first parameter, specify the Appearance Rule identifier (e.g., "FontColorRed"). Then, specify the following parameters.

  • In the module designer Rebuild Solution After making changes.

  • Conditions appearance rule to declare DemoTask class, set the "appearance properties" applied to such property. As the first parameter, specify appearance rule identifier (e.g., "FontColorRed"). Then, specify the following parameters.

Parameter Settings
Target UI elements to be affected by the rule. Set the AppearanceAttribute.AppearanceItemType parameter to "ViewItem" and the AppearanceAttribute.TargetItems parameter to "*". This means that the rule generated from the attribute will affect all DemoTask properties displayed in the current View.
Conditions under which the rule must be in effect. Set the AppearanceAttribute.Context parameter to "ListView" and the AppearanceAttribute.Criteria parameter to "Status!='Completed'". In this instance, the rule generated from the attribute will be in effect in a DemoTask List View for the object whose Status property is not set to Completed.
Conditional appearance applied by the rule. Set the AppearanceAttribute.FontColor named parameter to "Red".

The following code demonstrates the applied attribute and its parameters to the DemoTask class, that was declared in BusinessObjects\DemoTask.cs (DemoTask.vb) file.

The following code demonstrates the properties and parameters DemoTask class declaration in BusinessObjects_DemoTask.cs (DemoTask.vb) file in the application.

using DevExpress.ExpressApp.ConditionalAppearance;
// ...
[Appearance("FontColorRed", AppearanceItemType = "ViewItem", TargetItems = "*", Context = "ListView",
    Criteria = "Status!='Completed'", FontColor = "Red")]
public class DemoTask : Task {
    // ...
}

Note Note

The Criteria value must be specified using the Criteria Language Syntax.

You must use "conditional language syntax" conditions specified value.

  • Apply the AppearanceAttribute attribute to the DemoTask class' Priority property. As the first positional parameter, specify the Appearance Rule identifier (e.g., "PriorityBackColorPink"). Then, specify the following parameters.

  • The appearance attributes are applied to demonstrate task class "priority" attribute. Position as the first parameter, rule identifier specifies the appearance (e.g., "Priority pink color back"). Then, specify the following parameters.
  • Specify the target UI elements to be affected by the rule

    Set the AppearanceAttribute.AppearanceItemType parameter to "ViewItem". This means that the rule generated from the attribute will affect the Priority property displayed in the current View.

  • Targeting UI elements to be affected by the rule of
    the appearance of the property. Appearance project type parameter is set to "Show item." This means that the property is generated from the rule would affect the "priority" attribute displayed in the current view.
  • Specify the conditions under which the rule must be in effect

    Set the AppearanceAttribute.Context parameter to "Any" and the AppearanceAttribute.Criteria parameter to "Priority=2". In this instance, the rule generated from the attribute will affect the Priority property when it is set to 2 (High) in any DemoTask View.

  • Condition specifying rules must in effect
    be "appearance properties. Context" parameter is set to "any", the "appearance properties" standard parameter is set to "priority {2}." In this case, the rule generated from the property affects the "priority" attribute, when it is set to 2 (High) at any presentation task view.
  • Specify the conditional appearance applied by the rule

    Set the AppearanceAttribute.BackColor parameter to "255, 240, 240".

  • Conditions specify the appearance of the rule applied
    to attributes .BackColor appearance parameter is set to "255,240,240."

 

The following code demonstrates the applied attribute and its parameters.

The following code demonstrates the application of the property and its parameters.

public class DemoTask : Task {
    // ...
    [Appearance("PriorityBackColorPink", AppearanceItemType = "ViewItem", Context = "Any", 
        Criteria = "Priority=2", BackColor = "255, 240, 240")]
    public Priority Priority {
        // ...
    }
    // ...
}
  • Run the WinForms or ASP.NET application. The DemoTask List View and Detail View data will be highlighted, as demonstrated in the following image.

  • Run WinForms or ASP.NET applications. Demo task list view and the view data details will be highlighted, as shown below.

    Tutorial_EM_Lesson_5_7

Note Note
Appearence Rules that are declared in code are available in the Model Editor. To access them, you can run the Model Editor for the MySolution.Module project. Navigate to the BOModel | DemoTask | AppearanceRules node. This node has two child nodes (FontColorRed and PriorityBackColorPink) that are generated automatically from Appearance attributes applied to the DemoTask class and the DemoTask.Priority property. You can create new Appearance Rules directly in the Model Editor by adding child nodes to the AppearanceRules node.

在代码中声明的显示规则在模型编辑器中可用。要访问它们,您可以运行 MySolution.模块项目的模型编辑器。导航到 BOModel |演示任务 |外观规则节点。此节点有两个子节点(FontColorRed 和优先级BackColorPink),它们从应用于 DemoTask 类和 DemoTask.Priority 属性的外观属性自动生成。通过将子节点添加到"外观规则"节点,可以直接在模型编辑器中创建新的外观规则。

 

You can see the changes made in the lesson in the DemoTask.cs (DemoTask.vb) file located in the MainDemo.Module project of the MainDemo solution. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/

You can solve MainDemo program in mainDemo. Module project DemoTask.cs (DemoTask.vb) file to see changes made in this lesson. The demo application is installed in the main % the PUBLIC% \ Documents \ DevExpress the Demos 19.2 \ Components \ eXpressApp Framework \ MainDemo by default. The Available Online at The ASP.NET Version IS AT http://demos.devexpress.com/XAF/MainDemo/

.

Guess you like

Origin www.cnblogs.com/foreachlife/p/Highlight-List-View-Objects.html