Browse DevX
Sign up for e-mail newsletters from DevX


Write Apps for the Smartphone without Dumbing Down Your UI : Page 3

Learn how to change the text input modes and improvise the ContextMenu and TabControl controls using the Smartphone 2003 SDK for the .NET Compact Framework.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Improvising the Tab Control
Figure 6. Populating the Windows Form: The second Panel control overlaps the first one.
The Smartphone 2003 SDK does not support scrollable forms, which means that if you have more controls than what a single form can accommodate, you have to resort to creative techniques to display all these controls. And that can make the forms difficult to use. One way to solve that problem is to use a Tab control, to allow users to Tab their way from one control to another. But unfortunately, the Tab control isn't supported in the .NET CF either. In this section, I will show you how to improvise a Tab control using the Panel control.

Populate the Windows Form with the following controls:
a. Panel
b. MainMenu
c. Label
d. TextBox

The MainMenu control should have two main items named Exit and > (named mnuLeft and mnuRight respectively). Add a Panel control to the form and drag and drop a Label and a TextBox control to the Panel control. Then, repeat the same process by adding another Panel control that completely overlaps the first Panel control (see Figure 6):

First, declare a global variable:

Dim currentPage As Integer = 1

Code the following in the Load event of the Windows Form:

Private Sub Form9_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load Panel1.Visible = True Panel2.Visible = False End Sub

Code the following for the left menu item:

Private Sub mnuLeft_Click(ByVal sender As _ System.Object, _ ByVal e As System.EventArgs) _ Handles mnuLeft.Click Select Case currentPage Case 1 : Me.Close() Case 2 : mnuLeft.Text = "Exit" mnuRight.Text = ">" Panel1.Visible = True Panel2.Visible = False currentPage -= 1 ' Case 3: etc, etc End Select End Sub

Code the following for the right menu item:

Private Sub mnuRight_Click(ByVal sender As _ System.Object, _ ByVal e As System.EventArgs) _ Handles mnuRight.Click Select Case currentPage Case 1 : mnuLeft.Text = "<" mnuRight.Text = "Done" Panel1.Visible = False Panel2.Visible = True currentPage += 1 Case 2 : MsgBox(TextBox1.Text & " " & _ TextBox2.Text) ' Case 3: etc, etc End Select End Sub

Press F5 to debug and run the application. Figure 7 shows the final application running.
Figure 7. Better Use of Space: This application improvises use of the TabControl to allow multiple panels to overlap one another. The user tabs between them to navigate.
As you can see, much of the limitations of the Smartphone are due to the lack of a touch-screen. Unlike Pocket PCs, Smartphone users have to rely on the two soft keys on the phone for navigation. In addition, due to the memory and processing constraints of mobile devices, there is a limit to the number of managed classes supported in the .NET Compact Framework. Hence the designers of the .NET Compact Framework have to prioritize which are the most important functions to support, and inadvertently there will be some functions that you need that are not supported. As a Smartphone developer, you just have to live with these limitations and improvise your own solution to these problems! Or, wait for the next release of the .NET Compact Framework.

Wei-Meng Lee is a Microsoft .NET MVP and co-founder of Active Developer, a training company specializing in .NET and wireless technologies. He is a frequent speaker and author of numerous books on .NET, XML, and wireless technologies.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



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