Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)
Syntax
C# |
---|
public Object Value { get; set; } |
Visual Basic |
---|
Public Property Value As Object Get Set |
Visual C++ |
---|
public: property Object^ Value { Object^ get (); void set (Object^ value); } |
F# |
---|
member Value : Object with get, set |
Property Value
Type: ObjectThe value.
Remarks
When data is changed in business logic layer, the rows where this data is displayed should be sorted, filtrated, and grouped, and cells with this are repainted and highlighted as well
GridControl constantly monitors row state including their visibility, sorting position, grouping position and matching filtering conditions. Invocation of Row.Update method initiates verification of all the above conditions for a single row among ordered rows in a grid. This process is much more efficient than working with unsorted data, especially during sorting. Invocation of Row.Update in the event-driven model occurs regularly upon notification from the INotifyPropertyChanged interface. The Row.Update method call is thread-safe, and therefore you don't have to write your own thread synchronization logic. It is extremely convenient when you develop multi-threaded applications.
Therefore, when data is changed in the non-event model, you just have to invoke Row.Update / Cell.Update methods or Value setter, and GridControl will automatically perform all necessary operations with the row or with the cell
Copy | |
---|---|
public void DataUpdating(GridControl grid) { object[] data = new object[] { "value 1", 125, true, RowDockStyle.None }; Row row = grid.Rows.Add(data); //The next calls will invalidate and highlight cells, and sort, filter and regroup the row row[2].Value = false; row[3].Value = RowDockStyle.Top; //The last value in the data should equal to 'DockStyle.Top'. Debug.Assert(Equals(data[3], RowDockStyle.Top)); //This call will also invalidate and highlight the cell, and sort, filter and regroup the row data[1] = 125; row[1].Update(); //The next call will just sort, filter and regroup the row data[0] = "value 2"; row.Update(); } |
In the event-driven model it is sufficient to implement INotifyPropertyChanged interface to notify grid about data changes. This approach has very important advantages. The aforementioned interface is located in System.ComponentModel namespace and has only one public event - INotifyPropertyChanged.PropertyChanged. Because of that business logic can notify subscribers (GUI controls) through this interface and the GridControl itself performs data sorting, filtration and other operations. Moreover, a subscriber makes necessary actions for thread synchronization with the GUI thread. In other words, with good application architecture your assemblies with application logic will have no dependencies from presenattion logic and Dapfor assemblies.
This is an implementation of the popular OOP design pattern that is known as Observer or Publisher / Subscriber. This approach provides a considerable advantage over conventional programming models. Your applications may have multiple Graphic User Interfaces (multiple grids) that are subscribed to INotifyPropertyChanged.PropertyChanged event as event-listeners to the business object. A business object is an event generator or event publisher. When an object field changes in the setter of any property, the INotifyPropertyChanged.PropertyChanged event is fired and all subscribers get guaranteed notification about it:
Copy | |
---|---|
//Some data object public class Product : INotifyPropertyChanged { //Some fields private double price; private DateTime maturity; [DoubleConverter(Precision = 3, ShortForm = true, ShowZero = false)] public double Price { get { return price; } set { price = value; if(PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Price")); } } } public DateTime Maturity { get { return maturity; } } public event PropertyChangedEventHandler PropertyChanged; } //Add a data object to the grid. Product product = new Product(); Row row = grid.Rows.Add(product); //The grid will automatically sort, filter, group and highlight corresponding row! //The product is your business logic and may be placed in any assembly that doesn't need to have references to Dapfor assemblies! product.Price = 123; //The value in the "Price" cell should equal to '123'. Debug.Assert( Equals(123, row["Price"].Value) ); |
We would also like to emphasize performance advantages of the .Net Grid. In an unsorted grid all rows are systematically indexed, and when sorting is enabled, the search occurs at most ln(N) iterations due to efficient algorithms used in GridControl. It's obvious that storing row state data consumes memory. Average memory consumption per row equals to 160 bytes, and that results in 16 MB per 100,000 data objects inserted into the grid, while the performance advantage is tremendous! The grid with 2,000 rows enables updating of more than 50,000 cells and sorting of more than 3,000 rows per second in realtime!