Free Programming Books
Free download ebooks on computer and programming

Free Ebook ".NET Compact Framework Pocket Guide" Sample Chapter

.NET Compact Framework...
Free Download Project A: Currency Converter
Download chapter

Looking to create applications for Pocket PC and Windows based Smartphones? The new .NET Compact Framework Pocket Guide will teach you what you need to know. This handy reference provides a quick tour of the .NET Compact Framework and includes several working projects to get you productive straightaway. Whether you're new to mobile programming or new to Visual Studio .NET 2003, this pocket guide will get you started writing mobile applications.

< < prev next > >

Project A: Currency Converter

This first project shows how to develop a simple currency converter using the .NET Compact Framework's built-in controls. For simplicity, the sample application is limited to three currencies: U.S. Dollar, CNY (Chinese Yuan), and Singapore Dollar. This application downloads the currency

exchange rates from a web service when the application is first used. The application stores the rates in an XML document for subsequent usage.

Populating the Form with Controls

In Visual Studio .NET 2003, create a new Smart Device Application (File --> New --> Project, then select Visual Basic Projects --> Smart Device Application). Set the Pocket PC as the target device and select a project type of Windows Application. Your project should open with the default Form1.

Before you can add any of the controls, you need to set up two tab forms.

The application in this project contains one TabControl control, which in turn contains two TabPage controls. The first tab page is called Conversion, while the second is called Set Rates. The TabPage control lets you spread the controls across two pages.

To set it up, drag the TabControl from the toolbox onto the form. To add the tab page to a TabControl control, select the Tab-Control, right-click on it, and select Add Tab (see Figure 3-1).

To change the label of the TabPage, click the tab, select the TabPage (the region just above the tab), right-click on it, and select Properties. Change the Text property of the TabPage to Conversion. Do the same for the second tab page, but set its text to Set Rates. You should enlarge the TabControl so that it fills the form.

You must add the controls listed in Table 3-1 to this form (see Figures 3-2 and 3-3 for the layout). You'll also need to add an Options item to the default MainMenu1.