Monday, January 17, 2005
Resco AdvancedList Control 2.1 for .NET CF
Posted by Jimmy Dodd in "SOFTWARE" @ 10:00 AM
Events
The AdvancedList control fires several events in response to user actions. This makes the control not only very flexible as a data display, but also as an input control. In addition to the usual Paint, EnabledChanged, Got/LostFocus, Resize, and KeyPress style events, the AdvancedList control fires events for changing the active row, tapping on a cell, tapping on the header, tapping on a footer, tapping on a link cell, selecting a row, and tapping on the control in general. By differentiating between so many different user actions, the control can handle a great deal of the user interface on its own without having to resort to secondary controls such as menus or toolbars.
Data Binding
Binding the AdvancedList control to a DataTable or DataView is an easy, two-level process. Given a valid data adapter you simply set the DataSource member of the AdvancedList control to a valid DataTable or DataView object. Each Cell can then be bound to a specific column of the DataTable or DataView by ordinal number or by name. By using multiple RowTemplates with different Cell bindings different views of the data can be achieved with little programming effort.
If using a DataTable or DataView is overkill for your application, the AdvancedList control can be bound to any simple IList-derived class, such as an Array or an ArrayList. By setting each cell of the template to the name of a member of the object in the list that member is displayed in the cell. This makes it extremely easy to use the AdvancedList control in a truly object oriented design without having to resort to more generic DataTable or DataView collections.
XML
One feature that seems to be standard across Resco's .NET CF components is the ability to use XML files to store configuration information. Both the property window in Visual Studio .NET and the AdvancedList Designer include two additional links: Load and Save. Save allows you to export the current configuration information to an XML file, while Load reads in a previously saved XML file. All of the control's properties are contained in these files, including the RowTemplate definitions and data bindings.
Storing this information external to the application makes for easy modification of the look and feel of the application without having to recompile the source code. XML files can be edited by hand in any text editor, or a new layout can be created or modified in the AdvancedList Designer (with or without Visual Studio .NET) and copied to the device.
Dynamically loading the XML file at runtime is very simple as the AdvancedList control class contains a method for doing just that.
[code]
StreamReader stream = new StreamReader(@"\Program Files\RescoTests\MyXml.xml");
XmlTextReader reader = new XmlTextReader(stream);
advancedList1.LoadXml(reader);
[/code]









