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.