Skip to main content

How to: Create a Column and Assign an Editor to It

The following example demonstrates how to create a column within a View, and assign a specific editor to it.

    using DevExpress.XtraGrid.Views.BandedGrid;
    using DevExpress.XtraEditors.Repository;
    //...
    // Create a column
    BandedGridColumn col = advBandedGridView1.Columns.Add("Country") as BandedGridColumn;
    // Add a column to the first Band
    advBandedGridView1.Bands[0].Columns.Add(col);
    // Show the new column
    col.Visible = true;
    // Create a Repository Item
    RepositoryItemLookUpEdit columnEditor = new RepositoryItemLookUpEdit();
    // Customize the editor
    //...
    // Add the new Repository Item to the "RepositoryItems" collection
    gridControl1.RepositoryItems.Add(columnEditor);
    // Assign the editor to the new column
    col.ColumnEdit = columnEditor;

See the Cell Values, Editors, and Validation topic for more information about column editors.