One of the cells within a range selected by an end-user is the active cell. When an end-user types something, data is inserted into this cell. Usually, the active cell is the top left cell in the selected range. However, it can be any cell within the current selection. End-user can select a range by dragging a mouse with the CTRL key held down and then change the position of the active cell by clicking within the selected range. To obtain the active cell in code, use the SpreadsheetControl.ActiveCell, SpreadsheetControl.SelectedCell or Worksheet.SelectedCell property.
The Selection, SelectedCell and ActiveCell properties of the SpreadsheetControl object provide access to the selected cell range and active cell in the active worksheet. To specify the selected range and active cell in any other worksheet, use the Selection and SelectedCell properties of the corresponding Worksheet object. The following example demonstrates how to set borders around the cell range that is currently selected by an end-user, and apply a color to the active cell.
Private Shared Sub SelectedCell(ByVal control As SpreadsheetControl)
control.SelectedCell.FillColor = Color.LightGray
Dim c As CellRange = control.SelectedCell
c.FillColor = Color.Blue
Dim currentSelection As CellRange = control.Selection
Dim rangeFormatting As Formatting = currentSelection.BeginUpdateFormatting()
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.