Represents a cell

Namespace: Dapfor.Wpf.Controls
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)

Syntax

C#
public sealed class Cell
Visual Basic
Public NotInheritable Class Cell
Visual C++
public ref class Cell sealed
F#
[<SealedAttribute>]
type Cell =  class end

Remarks

The most common operations with cells include updating, determining location, blinking and some others:

 Copy imageCopy
public void MostCommonOperationsWithCell(GridControl grid)
{
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("Price"));
    grid.Headers[0].Add(new Column("Quantity"));
    grid.Rows.Add(new Product());
    Row row = grid.Rows[0];

    //Set a new price programmatically
    Cell cell = row["Price"];
    cell.Value = 52.32;
    //Edit cell with an appropriate editor
    grid.Headers[0]["Price"].Editable = true;

    //Blink cell with the red brush for 2 seconds
    cell.Blink(new TimeSpan(0, 0, 2), Brushes.Red);
    //Ensure cell visible
    cell.EnsureVisible();
    //Force the grid to resort the row and verify if the row should be filtered. I.e. if the IFilter.IsFiltered(row) returns true.
    //Normally this method is called automatically, if the data object implements INotifyPropertyChanged interface.
    cell.Update();
    //Just invalidate cell i.e. ask the grid to repaint cell without cheching for the position 
    //in the sorted order and checking if the row is filtered.
    cell.Invalidate();
}

Cell templatization enables usage of any controls in grid cells via data templates. Templates are usually defined as resources in XAML files. To use a template, it should be set in the required grid column.

Cell data templates enable simple binding to cell content. For this purpose an object of Cell type is transferred as Content. This object has many useful properties including Cell.Text can be used for displaying text.

An object of Cell type has Cell.Value property that can be used to get unformatted values of data objects. These values can be used in cell data templates via converters.

 Copy imageCopy
<!-- Resources --> 
<Window.Resources> 
  <TestApplication:MyCollection x:Key="someCollection" /> 
  <TestApplication:IntToFlagValueConverter x:Key="intToFlagConverter"/> 
  <DataTemplate x:Key="cellTemplate"> 
    <Grid> 
      <Image Source="{Binding Path=Value, Converter={StaticResource intToFlagConverter}}"/> 
      <Grid Grid.Column="1"> 
        <Ellipse Fill="Green"/> 
        <TextBlock Text="{Binding Path=Text}" HorizontalAlignment="Center" Foreground="Red"/> 
      </Grid> 
      <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="Auto"/> 
        <ColumnDefinition/> 
      </Grid.ColumnDefinitions> 
    </Grid> 
  </DataTemplate> 
</Window.Resources>

<!-- GridControl declaration --> 
<df:GridControl Name="grid"> 
<df:GridControl.Headers> 
  <df:Header> 
    <df:Header.Columns> 
      <df:Column Id="Value1" Title="Column 0" CellTemplate="{StaticResource cellTemplate}" Width="100" /> 
      <df:Column Id="Value2" Title="Column 1" Width="100" /> 
    </df:Header.Columns> 
  </df:Header> 
</df:GridControl.Headers> 
</df:GridControl>

Inheritance Hierarchy

System..::..Object
  Dapfor.Wpf.Controls..::..Cell

See Also