Back to Devexpress

How to: Add Virtual Rows Using the UnboundSource Component

windowsforms-116254-common-features-data-binding-how-to-add-virtual-rows-using-the-unboundsource-component.md

latest1.4 KB
Original Source

How to: Add Virtual Rows Using the UnboundSource Component

  • Oct 29, 2020
  • 3 minutes to read

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.

  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.