C1.WPF.FlexGrid Namespace > GridPanel Class : GetCellElement Method |
The default class factory uses System.Windows.Controls.Border elements to represent all cells. The border is responsible for rendering the cell's background color and the gridlines. The border contains the elements that represent the cell's actual content. In most cases, the border child is a simple System.Windows.Controls.TextBlock or System.Windows.Controls.CheckBoxelement that displays the cell content. Cells that contain text and graphics (e.g. sorted column headers and group rows) host a Grid element that contains the text and graphics elements.
This method can be useful in cases where you want to customize a cell after it has been created by the cell factory.
This method returns null if the requested range is not within the current view (see the C1FlexGrid.ViewRange property), or if the requested range does not match exactly the range represented by the cell (if the range is merged for example).
// loop through the cells in the current selection foreach (var cell in _flex.Selection.Cells) { // get element used to represent the cell var bdr = _flex.Cells.GetCellElement(cell) as Border; if (bdr != null) { // make it red bdr.Background = new SolidColorBrush(Colors.Red); } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2