Creating the User Interface for a Device Application

Create the user interface for a device application so users can run the application on a mobile device. The Windows Forms API and the Client Object API support user-interface development.

Prerequisites 
Before creating the application interface:
  1. Develop mobile business objects (MBOs) that implement the business logic for the application, and deploy them to Unwired Server. For the sample interface described here, create an MBO directly from the department table in the sampledb, and use the default mappings.
  2. Generate code for the device application.

This example describes how to build a simple user interface with one text field that displays the first record in the department table in the sampledb database.

Your user interface must provide the capability for users to enter the data required by the application.

  1. In the Solution Explorer, right-click the mobile application project, and select Build.
  2. Expand the mobile application project, and double-click Form1.cs.
  3. In the main menu, select Data > Add New Data Source .
  4. Select Object, then click Next.
  5. Expand the project, then expand the namespace (by default, Sybase.Mobile.App).
  6. Select Department, then click Finish.
  7. Select Data > Show Data Sources .
  8. In the Data Sources view, expand the Department table to display details.
  9. For each field in the Department table—except dept_name—click to the right of the field name, displaying a Down arrow, then select None.
  10. From the Data Sources view, drag the Department table icon, and drop it onto Form1 in the Mobile Application Designer. One text box is created in the form; its title is "Dept name."
  11. In the Solution Explorer, expand the mobile application project, right-click Form1.cs, and select View Code.
  12. In the constructor, after this line of code InitializeComponent();, add these lines to establish a connection, and synchronize the definition of the department MBO:
    Init.Instance.Connection();
    Department.Synchronize();
  13. Following the call to Synchronize, add the code to retrieve all instances of the department MBO from the database:
     List<Department> deptMBOs = Department.FindAll();
  14. Add this code to tie the first instance of the MBO to the user interface:
     if (deptMBOs.Count > 0)
     {
         this.departmentBindingSource.Add(deptMBOs[0]);
     }
  15. Save, then build the project.


Created September 17, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com