Or how to write a complete master detail view in 2 lines of code!
In my previous article I showed how it was possible to write a complete Windows Mobile 5 application in a ridiculously small amount of code. Using the full power of the Resco controls and the simplicity of the EntitySpaces architecture this can be simplified even more.
AdvancedList
The top half of our form uses the Resco AdvancedList control. This shows a complete list of all the rows in the Surveys collection. An un-selected row displays the contents of the column 'Name', a selected row expands to display two lines and now includes the column 'Address' in the second row.

The definition of this behavior is carried out at design time. Within the code all we have done is instantiated the 'Surveys' EntitySpaces collection and attached it to the AdvancedList using the collection as the datasource for the control.
this.advancedList1.DataSource = surveys;
The cell 'Address' we have created in the 'Selected' template has its CellSource set to Address, normally this property combination in the properties dialogue is collapsed and the ColumnName and SourceType are set correctly to their appropriate values by default.
DetailView
Recalling my previous article we used the Resco DetailView control to display the full details of the record. Most of the work required to achieve this was done in 3 lines of code.
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DataSource = types;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).DisplayMember
= HTypesMetadata.PropertyNames.Htype;
((Resco.Controls.DetailView.ItemComboBox)this.detailView1.Items["HType"]).ValueMember
= HTypesMetadata.PropertyNames.Id;
It is in fact possible to use the design time capability of the Resco control to eliminate all but the line which does the primary datasource binding, thus reducing this to just 1 line of code!
In the screen-shot above you can see the combobox properties being set using the DetailView designer.
In conclusion we have demonstrated some of the power of EntitySpaces when used in conjunction with sophisticated but easy to use Resco Controls. This approach can obviously be extended to any third party controls that properly support data binding in this way. Remember we have built a fully functional Master-Detail application without ever writing any SQL code at all !
Robert Campbell
ecommnet ltd., Bewick House, Horsley Business Centre, Horsley, Newcastle Upon Tyne, NE15 0NY UK
www.ecommnet.co.uk www.offexploring.com www.autobestbuy.co.uk