Skip to main content
A newer version of this page is available. .

Highlight Objects, Constructors, and Members

  • 4 minutes to read

You can allow the Data Source Wizard to filter classes, constructors, and data members that can be used to supply data, or display custom data source or member names.

Windows Forms and WPF applications

Use the HighlightedClass and HighlightedMember attributes in your code to make them available when users select to show only highlighted items. Use the DisplayName attribute to change the displayed name.

    using System.Collections.Generic;
    using DevExpress.DataAccess;
    using DevExpress.DataAccess.ObjectBinding;
    // ...

    public class Employee {
        public string Name { get; set; }
        public string Position { get; set; }
    }
    // The class that fetches data to the ObjectDataSource.
    [DisplayName("Employees")]
    [HighlightedClass]
    public class EmployeeDataSource {
        private string department;
        private List<Employee> management = new List<Employee>() {
            new Employee() {
                Name = "Ana Trujillo",
                Position = "CEO"
            },
            new Employee() {
                Name = "Andrew Fuller",
                Position = "Vice President, Sales"
            }
        };
        private List<Employee> financial = new List<Employee>() {
            new Employee() {
                Name = "Nancy Davolio",
                Position = "Accountant"
            },
            new Employee() {
                Name = "Maria Anders",
                Position = "Accountant"
            }
        };
        private List<Employee> sales = new List<Employee>() {
            new Employee() {
                Name = "Antonio Moreno",
                Position = "Sales Representative"
            },
            new Employee() {
                Name = "Thomas Hardy",
                Position = "Sales Representative"
            },
            new Employee() {
                Name = "Christina Berglund",
                Position = "Order Administrator"
            },
            new Employee() {
                Name = "Frédérique Citeaux",
                Position = "Marketing Manager"
            },
            new Employee() {
                Name = "Hanna Moos",
                Position = "Sales Representative"
            }
        };
        public Employees() {
            this.department = "Management";
        }
        // The HighlightedMember attribute highlights a constructor.
        [HighlightedMember]
        public Employees(string department) {
            this.department = department;
        }
        // The HighlightedMember attribute highlights a data member.
        [HighlightedMember]
        public IEnumerable<Employee> GetEmployeeList(int recordCount) {
            List<Employee> employees = new List<Employee>();
            if (this.department == "management")
                employees = this.management;
            if (this.department == "financial")
                employees = this.financial;
            if (this.department == "sales")
                employees = this.sales;
            foreach (var employee in employees)
                if (recordCount-->0)
                    yield return employee;
        }
    }

You can also apply the HighlightedAssembly attribute to the current assembly to add it to the assemblies list. Open the AssemblyInfo.cs file in the project’s Properties directory or the AssemblyInfo.vb file in the My Project directory in Visual Basic projects.

object-data-source-assemblyinfo

    using DevExpress.DataAccess.ObjectBinding;
    // ...
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: HighlightedAssembly]
    // ...

ASP.NET Applications

See the following topics for information on how to customize an object data source in an ASP.NET application’s Data Source Wizard: