Back to Devexpress

GridColumnCollection.AddField(String) Method

windowsforms-devexpress-dot-xtragrid-dot-columns-dot-gridcolumncollection-dot-addfield-x28-system-dot-string-x29.md

latest6.1 KB
Original Source

GridColumnCollection.AddField(String) Method

Creates a new hidden column which is bound to the specified field, and appends it to the collection.

Namespace : DevExpress.XtraGrid.Columns

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual GridColumn AddField(
    string fieldName
)
vb
Public Overridable Function AddField(
    fieldName As String
) As GridColumn

Parameters

NameTypeDescription
fieldNameString

A String value that specifies the name of the data field to which to bind the created column.

|

Returns

TypeDescription
GridColumn

A GridColumn object which represents the new column.

|

Remarks

Use the GridColumn.VisibleIndex property to control the column’s visibility.

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

reporting-winforms-label-report-in-code/CS/Reporting_how-to-create-a-label-report-at-runtime-t473792/Form1.cs#L61

csharp
lookUpLabelProduct.Properties.View.OptionsView.ShowIndicator = false;
GridColumn col1 = lookUpLabelProduct.Properties.View.Columns.AddField("Name");
col1.VisibleIndex = 0;

winforms-grid-use-layoutview-as-master-view/CS/WindowsApplication3/MasterDetailHelper.cs#L85

csharp
private GridColumn CreateColumn() {
    GridColumn column = view.Columns.AddField("Detail");
    column.Visible = true;

winforms-grid-use-coloredit-to-edit-unbound-column-string-values/CS/ColorEditExample/Form1.cs#L31

csharp
GridColumn unboundColumn = gridView1.Columns.AddField("Color");
unboundColumn.VisibleIndex = gridView1.Columns.Count;

winforms-grid-display-summary-calculated-over-detail-rows-in-master-row/CS/WindowsApplication59/Form1.cs#L23

csharp
gridControl1.ForceInitialize();
GridColumn col = gridView1.Columns.AddField("Tasks");
col.UnboundType = DevExpress.Data.UnboundColumnType.Integer;

reporting-winforms-label-report-in-code/VB/Reporting_how-to-create-a-label-report-at-runtime-t473792/Form1.vb#L53

vb
lookUpLabelProduct.Properties.View.OptionsView.ShowIndicator = False
Dim col1 As GridColumn = lookUpLabelProduct.Properties.View.Columns.AddField("Name")
col1.VisibleIndex = 0

winforms-grid-use-layoutview-as-master-view/VB/WindowsApplication3/MasterDetailHelper.vb#L95

vb
Private Function CreateColumn() As GridColumn
    Dim column As GridColumn = view.Columns.AddField("Detail")
    column.Visible = True

winforms-grid-use-coloredit-to-edit-unbound-column-string-values/VB/ColorEditExample/Form1.vb#L24

vb
gridView1.Columns("ColorString").Visible = False
Dim unboundColumn As GridColumn = gridView1.Columns.AddField("Color")
unboundColumn.VisibleIndex = gridView1.Columns.Count

winforms-grid-display-summary-calculated-over-detail-rows-in-master-row/VB/WindowsApplication59/Form1.vb#L19

vb
gridControl1.ForceInitialize()
Dim col As GridColumn = gridView1.Columns.AddField("Tasks")
col.UnboundType = DevExpress.Data.UnboundColumnType.Integer

See Also

VisibleIndex

GridColumnCollection Class

GridColumnCollection Members

DevExpress.XtraGrid.Columns Namespace