FlexGrid for WPF | ComponentOne
C1.WPF.FlexGrid.4.5.2 Assembly / C1.WPF.FlexGrid Namespace / GridPanel Class / GetCellElement Method
CellRange to locate.

In This Topic
    GetCellElement Method
    In This Topic
    Gets the System.Windows.FrameworkElement used to represent a cell on the panel.
    Public Function GetCellElement( _
       ByVal rng As CellRange _
    ) As FrameworkElement
    public FrameworkElement GetCellElement( 
       CellRange rng


    CellRange to locate.

    Return Value

    A System.Windows.FrameworkElement used to represent a cell on the panel.

    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).

    The code below turns the selected cells red:
    // 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);
    See Also