February 28, 2021
Hot Topics:

Mobile/PocketPC Development Jump Start

  • By Bradley L. Jones
  • Send Email »
  • More Articles »

Now that you've designed your form, you need to add the code. This is again done just as you would in a standard application. Double-click on the button to add code to its click event. You will be placed in the Form1.cs file in the button1_Click method. Add the code shown in bold to this method:

private void button1_Click(object sender, System.EventArgs e){   label1.Text = textBox1.Text + "\n" + label1.Text;   textBox1.Text = "";}

You'll see that this code is pretty simple. The first line places the current text in the textbox to the beginning of the label. A new line is used to separate the new text.

The next line is added to clear out the text in the textbox. You should note that when you enter these lines, you will see that the Intellisense helps you. All of the Intellisense features are available for building mobile applications just as they are in your standard applications. This line simply clears the textbox.

Go ahead and compile your application your application by pressing F5 or by selecting Start from the Debug menu. Note that if you get any errors, you should make sure your code is entered correctly. Additionally, I found that Form1 in the Main method was not always renamed when the form property was renamed. As such, you may need to change it to MyMobileAppForm.

If you don't get errors, the form will compile and deploy. You will see a message in the Build window such as this:

------ Deploy started: Project: MyMobileApp,       Configuration: Debug Pocket PC ------

After a few seconds (or minutes, depending on your machine), a pop-up will be displayed as shown in Figure 5.

Figure 5: The Deploy dialog

This dialog allows you to select from the valid devices connected to your machine for deployment. If you have a device, you can install to it provided it is connected to the machine. If not, you will still have the Pocket PC 2002 Emulator that you can deploy onto.

Select the Emulator and click the Deploy button. Again, your system will chug and churn as the emulator is loaded along with your application. When the emulator firsts loads, it will look like a standard PocketPC display. You should continue to wait while your application is loaded. Once loaded, your emulator should look like Figure 6.

Figure 6: Your Mobile Application running!

As you can see, the emulator looks—and will operate—like a real PocketPC device. You can enter text into the text box and click the Do It button. As you will see, the text is added to the label. All should work as expected. Figure 7 shows the emulator with a few lines of text entered.

Figure 7: Entered text in the mobile app!

Go ahead and close the mobile emulator window. When you do this, you may be prompted to save the emulator state or to close it. If you save the state, when you rerun your application from Visual Studio .NET 2003, it will start up quicker.

Page 2 of 3

This article was originally published on July 9, 2004

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date