Friday, March 26, 2004
Resco DetailView 2.0 Control for .NET CF
Posted by Jimmy Dodd in "DEVELOPER" @ 10:00 AM
Data Binding
Binding the DetailView 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 DetailView control to a valid DataTable or DataView object. Then, for each item you set the DataMember property to the appropriate column name. This requires each item to bind with the same table or view and keeps all items synchronized when navigating through rows.
XML
A handy feature that Resco has included in the DetailView control is a Load method that consumes an XML file and reconfigures the control. Thus the following code:
[code]
StreamReader stream = new StreamReader(@"\Program Files\RescoTests\MyXml.xml");
XmlTextReader reader = new XmlTextReader(stream);
detailView1.LoadXml(reader);
[/code]
reads in an XML file named MyXML.xml in the given folder and redisplays the DetailView control. Changes can be made to the control itself, to the items within the control, even adding and deleting items. Where do you get the XML file? The DetailView Designer has two handy buttons labeled Save and Load. As expected, Save takes the current control properties and saves them to a specified file in XML format. Likewise, Load allows you to read the properties from an XML file at design time.
Dynamically loading the control's properties can allow for variations and updates in the field without having to rebuild and redistribute the entire application. An application can simply check for the existence of an xml file on startup, using it to override the default values if it is present. Because the data binding properties for the DetailView are included in the XML file, a developer can completely change which columns are displayed in the form by swapping out a single XML file.









