Wraps an object of arbitrary class and provides access to it via reflection. Can be a part of event-driven model.

Namespace: Dapfor.Net.Data
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: (


public sealed class DataObjectAccessor : DataObjectAccessorBase
Visual Basic
Public NotInheritable Class DataObjectAccessor
	Inherits DataObjectAccessorBase
Visual C++
public ref class DataObjectAccessor sealed : public DataObjectAccessorBase
type DataObjectAccessor =  
        inherit DataObjectAccessorBase


In .Net 1.0 a very important interface was added to the System.ComponentModel namespace INotifyPropertyChanged. It is used to notify clients(typically binding clients) that a property value has changed. .Net Grid can bind to a data source for implementing such operations as automated real-time updates, sorting, filtering and data grouping. It's important to emphasize that all notifications are synchronized by the .Net Grid with GUI thread, which in turn means that data can be changed not only in GUI thread but also in any other thread, safely reporting to the .Net Grid about value changes.

A typical application consists of a set of classes that represent its business logic. In object-oriented programming this logic should always be present in some form. This business logic is represented by rows in the .Net Grid without regard to specific model used. When a programmer changes data object values in non-event-driven data grids, he has to find rows in the data grid and sort them, group them and verify their filtering criteria. It's important to remember that in well-designed applications it is necessary to take care about thread safety. In event-driven model, a data grid receives notifications about data changes and performs all the above mentioned operations.

 Copy imageCopy
//Some data object
public class Product : INotifyPropertyChanged
    //Some fields
    private double price;
    private DateTime maturity;

    [DoubleFormat(Precision = 3, ShortForm = true, ShowZero = false)]
    public double Price
        get { return price; }
            price = value;
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("Price"));

    public DateTime Maturity
        get { return maturity; }

    public event PropertyChangedEventHandler PropertyChanged;

//Using sample
public void AddDataObjectToGrid(Grid grid)
    //Initialize the grid
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("Price"));
    grid.Headers[0].Add(new Column("Maturity"));

    //Add a data object to grid. The object is implicitly wrapped with DataObjectAccessor
    grid.Rows.Add(new Product());

    //Add a data object to grid and wrap it explicitly with DataObjectAccessor
    //(You can provide your custom implementation of the data accessor). 
    grid.Rows.Add(new DataObjectAccessor(new Product()));

    //Build some hierarchy...
    grid.Rows[0].Add(new Product());

    //Or from another thread - this is safe.
        grid.Rows[0].Add(new Product());

Inheritance Hierarchy


See Also