Represents a cell

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public class Cell
Visual Basic
Public Class Cell
Visual C++
public ref class Cell
F#
type Cell =  class end

Remarks

The most common operations with cells include painting, editing, determining location, setting appearance, custom painting and some others:
 Copy imageCopy
public void MostCommonOperationsWithCell(Grid 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;
    cell.Edit();

    //Highlight cell with the red color for 2 seconds
    cell.Highlight(new TimeSpan(0, 0, 2), Color.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();

    //Set a back color for cell
    cell.Appearance.BackColor = Color.Green;

    //Set some image
    Bitmap image = new Bitmap("Image.ico");
    cell.Image = image;

    //Demonstrates, how to custom draw in cell. 
    //The delegate is called while cell's painting
    grid.PaintCell += delegate(object sender, PaintCellEventArgs e)
    {
        using(Brush brush = new SolidBrush(Color.DeepPink))
        {
            //Prevent from text painting
            e.Parts &= e.Parts ^ PaintPart.Text;

            //Set a new background color
            e.Appearance.BackColor = Color.Yellow;

            //Do default painting without the text drawing
            e.PaintAll();
            e.Handled = true;

            //Draw a custom text above already pained cell
            e.Graphics.DrawString("Custom string", SystemFonts.StatusFont, brush, e.Cell.VirtualBounds);
        }
    };
}

Inheritance Hierarchy

System..::..Object
  Dapfor.Net.Ui..::..Cell

See Also