Back to Devexpress

LookUpColumnInfoCollection.Add(LookUpColumnInfo) Method

windowsforms-devexpress-dot-xtraeditors-dot-controls-dot-lookupcolumninfocollection-dot-add-x28-devexpress-dot-xtraeditors-dot-controls-dot-lookupcolumninfo-x29.md

latest5.2 KB
Original Source

LookUpColumnInfoCollection.Add(LookUpColumnInfo) Method

Adds a new column to the current collection.

Namespace : DevExpress.XtraEditors.Controls

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public virtual int Add(
    LookUpColumnInfo column
)
vb
Public Overridable Function Add(
    column As LookUpColumnInfo
) As Integer

Parameters

NameTypeDescription
columnLookUpColumnInfo

A column to add to the collection.

|

Returns

TypeDescription
Int32

The position into which the new element was inserted.

|

Remarks

Use the Add method to add a new element to the collection. The column to add is passed as the column parameter. To add several columns at once, see the LookUpColumnInfoCollection.AddRange method.

Example

The following code adds two columns to the RepositoryItemLookUpEdit.Columns collection of a lookup editor. For each column we initialize its field, caption and width.

csharp
using DevExpress.XtraEditors.Controls;
//...
lookUpEdit1.Properties.Columns.Add(new LookUpColumnInfo("ID", "No", 20));
lookUpEdit1.Properties.Columns.Add(new LookUpColumnInfo("Name", "Customer Name", 80));
vb
Imports DevExpress.XtraEditors.Controls
' ...
LookUpEdit1.Properties.Columns.Add(New LookUpColumnInfo("ID", "No", 20))
LookUpEdit1.Properties.Columns.Add(New LookUpColumnInfo("Name", "Customer Name", 80))

The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(LookUpColumnInfo) 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.

winforms-lookup-show-custom-tooltips/CS/LookUpEditWithHints/Form1.cs#L31

csharp
LookUpColumnInfoCollection coll = lookUpEditHints1.Properties.Columns;
coll.Add(new LookUpColumnInfo("Customer"));
coll.Add(new LookUpColumnInfo("Description"));

winforms-scheduler-sync-google-event-colors-with-labels/CS/SchedulerGSync/SchedulerGSync/SyncOptionsForm.cs#L31

csharp
this.lookUpEdit1.Properties.Columns.Clear();
this.lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Summary"));
this.lookUpEdit1.EditValue = CalendarId;

winforms-lookup-show-custom-tooltips/VB/LookUpEditWithHints/Form1.vb#L26

vb
Dim coll As LookUpColumnInfoCollection = lookUpEditHints1.Properties.Columns
coll.Add(New LookUpColumnInfo("Customer"))
coll.Add(New LookUpColumnInfo("Description"))

winforms-scheduler-sync-google-event-colors-with-labels/VB/SchedulerGSync/SchedulerGSync/SyncOptionsForm.vb#L34

vb
Me.lookUpEdit1.Properties.Columns.Clear()
Me.lookUpEdit1.Properties.Columns.Add(New DevExpress.XtraEditors.Controls.LookUpColumnInfo("Summary"))
Me.lookUpEdit1.EditValue = CalendarId

See Also

AddRange(LookUpColumnInfo[])

LookUpColumnInfoCollection Class

LookUpColumnInfoCollection Members

DevExpress.XtraEditors.Controls Namespace