RepositoryItemLookUpEdit.PopulateColumns() Method

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

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v21.1.dll


public virtual void PopulateColumns()


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.

See Also