C1.Silverlight.FlexGrid.5
GetCellElement Method
Example 

CellRange to locate.
Gets the System.Windows.FrameworkElement used to represent a cell on the panel.
Syntax
'Declaration
 
Public Function GetCellElement( _
   ByVal rng As CellRange _
) As System.Windows.FrameworkElement
public System.Windows.FrameworkElement GetCellElement( 
   CellRange rng
)

Parameters

rng
CellRange to locate.

Return Value

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

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

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

Reference

GridPanel Class
GridPanel Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.