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

RepositoryItemLookUpEdit.PopulateColumns() Method

Creates columns for all fields available in the lookup data source (RepositoryItemLookUpEditBase.DataSource).

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

public virtual void PopulateColumns()

Remarks

If no columns are explicitly created in the RepositoryItemLookUpEdit.Columns collection, the lookup editor automatically creates columns (by calling the PopulateColumns method) at runtime when the editor’s dropdown is invoked for the first time. You can manually call the PopulateColumns method in code to get access to columns and perform additional customization.

The PopulateColumns method deletes existing columns from the RepositoryItemLookUpEdit.Columns collection and then adds new columns to this collection for all fields found in the RepositoryItemLookUpEditBase.DataSource. You can use methods of the RepositoryItemLookUpEdit.Columns collection if you need to add, remove or access individual columns.

At design time, you can retrieve fields from the bound lookup data source and create corresponding columns via the control’s smart tag (for standalone editors) or by clicking the Populate Columns button in the Column Collection Editor. To activate this editor, click the ellipsis (…) button for the RepositoryItemLookUpEdit.Columns property in the Properties window.

Each column in a lookup editor is an instance of the LookUpColumnInfo class. The PopulateColumns method sets the LookUpColumnInfo.FieldName and LookUpColumnInfo.Caption properties to the corresponding field names in the lookup data source.

If a field specifies a date/time value, the corresponding column’s LookUpColumnInfo.FormatType is set to FormatType.DateTime and FormatInfo.FormatString is set to the Short Date Format.

For numeric fields, the column’s LookUpColumnInfo.FormatType is set to FormatType.Numeric and the LookUpColumnInfo.Alignment is set to HorzAlignment.Far. For non-numeric fields, the alignment is set to HorzAlignment.Near.

After all columns have been created, the method calls RepositoryItemLookUpEdit.BestFit in order to calculate column widths according to their contents.

The following code snippets (auto-collected from DevExpress Examples) contain references to the PopulateColumns() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also