When the data layer is linked to the graphical controls so that there is independence of the data on the presentation, this process is known as data binding. Nowadays, data binding is heavily used in many applications. The WinForms and WPF applications also use the data binding method. Just for the sake of data binding it should not be done, it must be implemented in such a manner that the application is stable as well as useful. If any kind of mistake is committed during the design phase the result can be catastrophic on the application. Dapfor comes with an easy way with which developers can use the data binding technique in their application.
.Net grid uses the data binding methodology in the .Net Grid for the purpose of implementing various data collection of IList, IBindingList, IListSource type. Dapfor also provides features with which data binding can operate in unbound mode. If develops want to add data one by one on the grid which is not available in the data binding list you can use the following to do that:
//Build a header with columns
grid.Headers.Add(new Header());
grid.Headers[0].Add(new Column("IntValue"));
grid.Headers[0].Add(new Column("DoubleValue"));
grid.Headers[0].Add(new Column("StringValue"));
//Add data object at the top-level and attach 2 children of the same type
Row row1 = grid.Rows.Add(new MyCustomClass(10, 11.11, "item 1"));
row1.Add(new MyCustomClass(11, 11.22, "subitem 1"));
row1.Add(new MyCustomClass(12, 11.22, "subitem 2"));
//Add data other data object with 2 children
Row row2 = grid.Rows.Add(new MyCustomClass(20, 22.11, "item 2"));
row2.Add(new MyCustomClass(22, 22.22, "subitem 1"));
row2.Add(new MyCustomClass(22, 22.22, "subitem 2"));
In here hierarchical data binding is also possible with the help of Row type of objects. .Net Grid also provides provision to add as many headers as possible which changes the presentation of the treelist. For example:
grid.Headers.Add(new Header());
grid.Headers[1].Add(new Column("DoubleValue"));
grid.Headers[1].Add(new Column("StringValue"));
In this unbound mode of data binding .Net Grid supports all type of data types which makes the job very easy for the developers.
//Add an array of objects on the top level
Row row = grid.Rows.Add(new object[] { 10, 11.12, "some string 1" });
//Add a dictionary as a child object
IDictionary<string, object> dataObject2 = new Dictionary<string, object>();
dataObject2.Add("IntValue", 20);
dataObject2.Add("DoubleValue", 21.33);
row.Add(dataObject2);
//Add an object with variable number of fields as a child of the row
Row childRow = row.Add(new UnboundValueAccessor());
childRow["StringValue"].Value = "some value";
Unbound mode is very suitable method for data binding when the amount of data doesn’t changes and when data is only added not removed. While implementing the data binding in the .Net Grid, if developers implement the INotifyPropertyChanged interface in the data objects the grid becomes event drive application. The .Net grid will now receive all the notifications in real-time such as update, sort, highlights etc and the changes are also up-to-date. This is an additional benefit of using the data binding in the .Net Grid.
.Net grid uses the data binding methodology in the .Net Grid for the purpose of implementing various data collection of IList, IBindingList, IListSource type. Dapfor also provides features with which data binding can operate in unbound mode. If develops want to add data one by one on the grid which is not available in the data binding list you can use the following to do that:
//Build a header with columns
grid.Headers.Add(new Header());
grid.Headers[0].Add(new Column("IntValue"));
grid.Headers[0].Add(new Column("DoubleValue"));
grid.Headers[0].Add(new Column("StringValue"));
//Add data object at the top-level and attach 2 children of the same type
Row row1 = grid.Rows.Add(new MyCustomClass(10, 11.11, "item 1"));
row1.Add(new MyCustomClass(11, 11.22, "subitem 1"));
row1.Add(new MyCustomClass(12, 11.22, "subitem 2"));
//Add data other data object with 2 children
Row row2 = grid.Rows.Add(new MyCustomClass(20, 22.11, "item 2"));
row2.Add(new MyCustomClass(22, 22.22, "subitem 1"));
row2.Add(new MyCustomClass(22, 22.22, "subitem 2"));
In here hierarchical data binding is also possible with the help of Row type of objects. .Net Grid also provides provision to add as many headers as possible which changes the presentation of the treelist. For example:
grid.Headers.Add(new Header());
grid.Headers[1].Add(new Column("DoubleValue"));
grid.Headers[1].Add(new Column("StringValue"));
In this unbound mode of data binding .Net Grid supports all type of data types which makes the job very easy for the developers.
//Add an array of objects on the top level
Row row = grid.Rows.Add(new object[] { 10, 11.12, "some string 1" });
//Add a dictionary as a child object
IDictionary<string, object> dataObject2 = new Dictionary<string, object>();
dataObject2.Add("IntValue", 20);
dataObject2.Add("DoubleValue", 21.33);
row.Add(dataObject2);
//Add an object with variable number of fields as a child of the row
Row childRow = row.Add(new UnboundValueAccessor());
childRow["StringValue"].Value = "some value";
Unbound mode is very suitable method for data binding when the amount of data doesn’t changes and when data is only added not removed. While implementing the data binding in the .Net Grid, if developers implement the INotifyPropertyChanged interface in the data objects the grid becomes event drive application. The .Net grid will now receive all the notifications in real-time such as update, sort, highlights etc and the changes are also up-to-date. This is an additional benefit of using the data binding in the .Net Grid.