Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
public event EventHandler<GridRowAddingEventArgs> RowAdding |
Visual Basic |
---|
Public Event RowAdding As EventHandler(Of GridRowAddingEventArgs) |
Visual C++ |
---|
public: event EventHandler<GridRowAddingEventArgs^>^ RowAdding { void add (EventHandler<GridRowAddingEventArgs^>^ value); void remove (EventHandler<GridRowAddingEventArgs^>^ value); } |
F# |
---|
member RowAdding : IEvent<EventHandler<GridRowAddingEventArgs>, GridRowAddingEventArgs> |
Value
Type: System..::..EventHandler<(Of <(<'GridRowAddingEventArgs>)>)>Remarks
Conditional binding is one of the most powerful and convenient types of binding. It is an API provided by the grid that enables the programmer to specify insertion method when a data object is added to the grid. The API is implemented as an event that is called when data is added to the grid.
This event contains a reference to the added object, a parent row if any and insertion method for this object. Below is the list of possible actions upon data insertion to the grid:
- AsChild - regular method of data object insertion to parent. A programmer may replace the inserted object with any other object on his own discretion.
- AsCollection - a programmer may replace a data object with any collection that shall be added instead of the specified object.
- AsChildAndCollection - the grid adds a data object and a new collection. The data object is added to the specified parent as with AsChild, and the collection is added on the next hierarchy level to the data object that has just been added.
- Skip - the data object is not added to the grid.
It is important to note that if a collection implements IBindingList interface, the grid subscribes to events of this collection and inserts or modifies data on corresponding hierarchy level of the grid. All binding list operations are thread safe.
Examples
Copy | |
---|---|
//Basket class public class Basket { //Private fields private readonly BindingList<Order> _orders = new BindingList<Order>(); //Public properties public IList<Order> Orders { get { return _orders; } } } //Initialize the grid public void InitializeGrid(Grid grid, IList<Basket> baskets) { grid.RowAdding += OnGridRowAdding; //Bind the grid to basket collection grid.DataSource = baskets; } private void OnGridRowAdding(object sender, GridRowAddingEventArgs e) { //Skip the 'basket' level and bind orders directly to basket's parent Basket basket = e.DataObject as Basket; if (basket != null) { e.DataObject = basket.Orders; e.InsertionType = InsertionType.AsCollection; } } |