Back to Devexpress

Highlight Objects, Constructors, and Members

xtrareports-401929-feature-guide-to-devexpress-reports-bind-reports-to-data-business-object-highlight-objects-constructors-and-members.md

latest8.2 KB
Original Source

Highlight Objects, Constructors, and Members

  • Feb 18, 2026
  • 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.

Highlighted Assembly

Highlighted Class

Highlighted Member

csharp
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;
        }
    }
vb
Imports System.Collections.Generic
    Imports DevExpress.DataAccess
    Imports DevExpress.DataAccess.ObjectBinding
    ' ...

    Public Class Employee
        Public Property Name() As String
        Public Property Position() As String
    End Class
    ' The class that fetches data to the ObjectDataSource.
    <DisplayName("Employees"), HighlightedClass>
    Public Class EmployeeDataSource
        Private department As String
        Private management As New List(Of Employee)() From {
            New Employee() With {.Name = "Ana Trujillo", .Position = "CEO"},
            New Employee() With {.Name = "Andrew Fuller", .Position = "Vice President, Sales"}
        }
        Private financial As New List(Of Employee)() From {
            New Employee() With {.Name = "Nancy Davolio", .Position = "Accountant"},
            New Employee() With {.Name = "Maria Anders", .Position = "Accountant"}
        }
        Private sales As New List(Of Employee)() From {
            New Employee() With {.Name = "Antonio Moreno", .Position = "Sales Representative"},
            New Employee() With {.Name = "Thomas Hardy", .Position = "Sales Representative"},
            New Employee() With {.Name = "Christina Berglund", .Position = "Order Administrator"},
            New Employee() With {.Name = "Frédérique Citeaux", .Position = "Marketing Manager"},
            New Employee() With {.Name = "Hanna Moos", .Position = "Sales Representative"}
        }
        Private Function Employees() As Public
            Me.department = "Management"
        End Function
        ' The HighlightedMember attribute highlights a constructor.
        <HighlightedMember>
        Private Function Employees(ByVal department As String) As Public
            Me.department = department
        End Function
        ' The HighlightedMember attribute highlights a data member.
        <HighlightedMember>
        Public Iterator Function GetEmployeeList(ByVal recordCount As Integer) As IEnumerable(Of Employee)
            Dim employeesList As New List(Of Employee)()
            If Me.department = "management" Then
                employeesList = Me.management
            End If
            If Me.department = "financial" Then
               employeesList = Me.financial
            End If
            If Me.department = "sales" Then
                employeesList = Me.sales
            End If
            For Each employee In employeesList
                Dim tempVar As Boolean = recordCount>0
                recordCount -= 1
                If tempVar Then
                    Yield employee
                End If
            Next employee
        End Function
    End Class

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.

csharp
using DevExpress.DataAccess.ObjectBinding;
    // ...
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: HighlightedAssembly]
    // ...
vb
Imports DevExpress.DataAccess.ObjectBinding
    ' ...
    <Assembly: AssemblyTrademark("")> 
    <Assembly: ComVisible(False)>
    <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: