DataBinding in C1TileControl

After the release of Tiled-Windows8, the new tile-based user interface (UI) is the most 'in-thing' these days. Who would not prefer to provide quick navigation and better UI to their application. The Windows 8-inspired C1TileControl for WinForms makes it easy to replicate the Windows 8 Modern UI experience in your desktop applications. With the new feature of DataBinding, it has become every developers first choice. Img_C1Tile C1TileControl can universally bind to any generic .NET data source. Requiring little or no code at all, it can create a fully-navigational database browser in mere seconds. C1TileControl fully supports complex data binding to ADO.NET objects such as DataTable, DataView and DataSet. We just need to set the DataSource and DataMember properties and we are good to go. These properties can be set both through code and through the Visual Studio's Properties window. The various properties and events that are added for databinding in C1TileControl are discussed below : DataSource and DataMember properties : These are the basic properties that need to be set to achieve databinding in C1TileControl. It also makes it possible to load tiles dynamically from a data source at runtime. When some data is changed in the associated data source, all tiles would be recreated automatically. PropertyMappings collection property : The collection consists of the PropertyMapping objects that is required to establish an association between the property of an item from data source and the property of the corresponding Tile component. FilterItem event : The event would be fired every time an item is loaded from the data source. The creation of a Tile for the given item can be skipped by setting e.Skip to True in this event handler. Code :

System.Data.DataRowView rv = (System.Data.DataRowView)e.Item;  
 if (rv["Country"].ToString() == "Spain")  
 e.Skip = true;  

FormatValue event : The event would be fired when a data value has to be mapped to a tile property. The event can be used to convert a value to the appropriate data type or to generate value for a given data item. For example, this event can be used to make a background color dependent on a Decimal value obtained from the data source. Code :

if (e.TileProperty == C1.Win.C1Tile.TileProperty.Group)  
   if (e.Value.ToString() == "Germany")  
        e.Value = e.Value.ToString().ToUpper();  

CompareGroups/CompareTiles events : These events occur when sorting groups and tiles after filling from a data source. They allows the user to compare two groups or two tiles and make a decision which of those items should precede the other in the corresponding collection. Code :

// comparing Tiles  
 e.Tile1.BackColor = e.Tile1.Text.StartsWith("Philip") ? Color.Khaki : e.Tile1.BackColor;

Refer to the sample for complete implementation of the above mentioned events/properties. Download Sample


GrapeCity Developer Tools
comments powered by Disqus