Back to Devexpress

ColumnCollection.Item[Int32] Property

officefileapi-devexpress-dot-spreadsheet-dot-columncollection-dot-item-x28-system-dot-int32-x29.md

latest3.1 KB
Original Source

ColumnCollection.Item[Int32] Property

Provides indexed access to individual columns in the collection.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Column this[int columnIndex] { get; }
vb
ReadOnly Property Item(columnIndex As Integer) As Column

Parameters

NameTypeDescription
columnIndexInt32

A zero-based integer specifying the desired column’s position within the collection. If it’s negative or exceeds the last available index (a worksheet limits the number of columns to 16384), an exception is raised.

|

Property Value

TypeDescription
Column

A Column object which specifies the column at the specified position.

|

Remarks

Use the Item property to access individual columns using index notation.

Example

This example demonstrates how to access columns in a worksheet. Use the Worksheet.Columns property to get a collection of columns contained in a worksheet (the ColumnCollection object). To get an individual column by its index (zero-based) or heading (“A”, “B”, “C”, etc.), use the ColumnCollection.Item property.

csharp
using DevExpress.Spreadsheet;
// ...

Workbook workbook = new Workbook();

// Access a collection of columns.
ColumnCollection columns = workbook.Worksheets[0].Columns;

// Access the first column by its index in the collection of columns.
Column firstColumn_byIndex = columns[0];

// Access the first column by its unique name.
Column firstColumn_byName = columns["A"];
vb
Imports DevExpress.Spreadsheet
' ...

Dim workbook As New Workbook()

' Access a collection of columns.
Dim columns As ColumnCollection = workbook.Worksheets(0).Columns

' Access the first column by its index in the collection of columns.
Dim firstColumn_byIndex As Column = columns(0)

' Access the first column by its unique name.
Dim firstColumn_byName As Column = columns("A")

See Also

ColumnCollection Interface

ColumnCollection Members

DevExpress.Spreadsheet Namespace