[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Bind to JSON Data
    Bind to XPO Data
    Bind to Azure SQL Database
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
   Find Panel Syntax
  [Expand]Graphics Performance and High DPI
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML-inspired Text Formatting
  [Expand]Save and Restore Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Add Virtual Rows Using the UnboundSource Component

A data-aware control bound to a data source can require additional items to display. Such items, which are shown by a control but not stored within its underlying data source, are called virtual or unbound rows. This example demonstrates how to implement such rows using the UnboundSource component.

  1. Virtual rows are frequently needed when working with lookup editors - these often need to display service items like "All" or "None" in their drop-down lists. So start with adding the UnboundSource component and LookUpEdit control onto your form.
  2. Use the UnboundSource component to provide data for your lookup editor. The entire process is explained in this article. Below is a brief description of what you will need to do.

    • Prepare an external data set. For this sample application you can use a List structure populated with simple entities as shown below.

    • Add data fields to your UnboundSource component. Field names must refer to existing data set fields.
    • Assign the UnboundSource component to the editor's RepositoryItemLookUpEditBase.DataSource property.
    • Specify the editor's RepositoryItemLookUpEditBase.DisplayMember and RepositoryItemLookUpEditBase.ValueMember properties.
  3. Call the component's SetRowCount method to specify how many items your lookup should display. Typically, you would use the actual data set row count as the method's parameter. Since we need multiple additional rows, use a higher value as shown below.

  4. Finally, handle the component's ValueNeeded event and add the required amount of virtual rows.

    The result is shown in the following figure.

Is this topic helpful?​​​​​​​