officefileapi-devexpress-dot-spreadsheet-dot-cell.md
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
int ColumnIndex { get; }
ReadOnly Property ColumnIndex As Integer
| Type | Description |
|---|---|
| Int32 |
A zero-based integer value that specifies the index of the column containing the current cell.
|
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
// 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
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
' 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
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