Back to Devexpress

Cell.ColumnIndex Property

officefileapi-devexpress-dot-spreadsheet-dot-cell.md

latest4.2 KB
Original Source

Cell.ColumnIndex Property

Gets the index of the column that contains the current cell.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
int ColumnIndex { get; }
vb
ReadOnly Property ColumnIndex As Integer

Property Value

TypeDescription
Int32

A zero-based integer value that specifies the index of the column containing the current cell.

|

Remarks

Use the ColumnIndex and Cell.RowIndex properties to obtain indexes of the column and row at the intersection of which the current cell is located. To get column and row headings, use the Column.Heading and Row.Heading properties.

To get the string that specifies a cell reference, call the CellRange.GetReferenceA1 or CellRange.GetReferenceR1C1 method for this cell.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ColumnIndex property.

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-spreadsheet-use-formula-engine/CS/FormulaEngineTest/Form1.cs#L64

csharp
// Get coordinates of the context cell.
int columnIndex = this.contextCell.ColumnIndex;
int rowIndex = this.contextCell.RowIndex;

winforms-spreadsheet-custom-draw-example/CS/WindowsFormsApp1/Form1.cs#L172

csharp
if (e.ColumnIndex <= 4) {
    var backColor = e.IsHovered || (e.ColumnIndex == spreadsheetControl1.ActiveCell.ColumnIndex) ?
        //Color 1

winforms-spreadsheet-use-formula-engine/VB/FormulaEngineTest/Form1.vb#L60

vb
' Get coordinates of the context cell.
Dim columnIndex As Integer = Me.contextCell.ColumnIndex
Dim rowIndex As Integer = Me.contextCell.RowIndex

winforms-spreadsheet-custom-draw-example/VB/CustomDrawExample/Form1.vb#L67

vb
If e.ColumnIndex <= 4 Then
    Dim backColor = If(e.IsHovered OrElse (e.ColumnIndex = spreadsheetControl1.ActiveCell.ColumnIndex),
        Color.FromArgb(200, 44, 74), 'Color 1

See Also

RowIndex

Row.Index

Column.Index

Cell Interface

Cell Members

DevExpress.Spreadsheet Namespace