A callback that is called by Filter to determene whether Row is filtered

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

Syntax

C#
public delegate bool Callback(
	Row row
)
Visual Basic
Public Delegate Function Callback ( 
	row As Row
) As Boolean
Visual C++
public delegate bool Callback(
	Row^ row
)
F#
type Callback = 
    delegate of 
        row : Row -> bool

Parameters

row
Type: Dapfor.Net.Ui..::..Row

Return Value

Type: Boolean

Remarks

Demonstrates how to set and use the filter
 Copy imageCopy
//Some data object
public class Product : INotifyPropertyChanged
{
    private double price;

    public double Price
    {
        get { return price; }
        set
        {
            //If the price is not the same, change it and notify about price changing
            if (price != value)
            {
                price = value;
                //The event can be raised from any thread. The grid will synchronize thread with GUI without blocking the calling thread.
                //While painting, sorting or filtering the grid can ask this object in the GUI (!) thread to get a value.
                if(PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Price"));
                }
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

public void HowToSetFilter(Grid grid)
{
    //Set a filter that hides all rows, that contain products with price less than 10
    grid.Filter = new Filter(delegate(Row row)
    {
        //There are three ways to get price: 
        //1. From the Cell through the Value property, which returns a double value: row["Price"].Value
        //2. Through the IDataAccessor and IDataField: row.DataAccessor["Price"].Value
        //3. From the data object itself: ((Product)row.DataObject).Price

        if ((double)row["Price"].Value < 10)
        {
            //Filter the row
            return true;
        }

        //The row is not filtered
        return false;
    });

    //Populate the grid
    Product product1 = new Product();
    Product product2 = new Product();

    grid.Rows.Add(product1);
    grid.Rows.Add(product2);

    //Update the product's price
    //Data objects will notify the Grid, and it will display only the product2. 
    //The product1 will be hidden
    product1.Price = 9;
    product2.Price = 11;
}

See Also