Skip to main content

RepositoryItemLookUpEdit.ForceInitialize() Method

Finishes the initialization of the LookUp editor’s data source. Call this method when the form is loading, before you start to create columns or obtain column values.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v22.2.dll

NuGet Package: DevExpress.Win.Navigation


public virtual void ForceInitialize()


The ForceInitialize method initializes the editor’s data source so you can safely create columns or obtain column values on a form’s load (for instance, in the Form.Load event handler).


The ForceInitialize method does not create lookup columns. Call the PopulateColumns() method to generate columns for the data source fields.

This example demonstrates how to initialize a LookUpEdit or its repository item during form load.

using DevExpress.XtraEditors.Repository;

private void Form1_Load(object sender, EventArgs e) {
    RepositoryItemLookUpEdit lookUpEdit = new RepositoryItemLookUpEdit();
    lookUpEdit.DataSource = new List<DataObject> {
        new DataObject { ID = 1, Text = "One" },
        new DataObject { ID = 2, Text = "Two" },
        new DataObject { ID = 3, Text = "Three" }
    lookUpEdit.ValueMember = nameof(DataObject.ID);
    lookUpEdit.DisplayMember = nameof(DataObject.Text);

    // Initializes the lookup's data source and internal infrustructure.

    // Now, you can safely populate lookup columns.

    // Access columns and obtain column values.
    var column = lookUpEdit.Columns[nameof(DataObject.Text)];
    string columnValue = lookUpEdit.GetDataSourceValue(column, 1) as string; // columnValue = "Two"
    object keyValue = lookUpEdit.GetKeyValueByDisplayValue(column); // keyValue = 2
See Also