views:

323

answers:

1

I am a bit new to Windows Mobile (with C# and the compact framework) development, so I am kind of unsure how to do this. The user has to go through several pages of information in a wizard-like manner. At the start there is a login window.

How would I go about and implement this? Would I just have different User Controls for each page and create/show and destroy/hide them on request? Or do I need to create different forms and somehow show those?

+2  A: 

I would use a TabControl to "simulate" a wizard (note that I have not personally used a TabControl in a Windows Mobile/Compact FrameWork context, but it is listed officially by Microsoft as part of the FrameWork for "Windows CE, Windows Mobile for Pocket PC." See :TabControl

In WinForms there's an easy trick to hide the tabs if you want to create a wizard-like user-experience: in the Form 'Load event set the Region of the Tabcontrol to the DisplayRectangle of the TabControl.

tabControl1.Region = new Region(tabControl1.DisplayRectangle);

If that works for you, it will save you a lot of trouble of moving 'UserControls or 'Panels around, and you can design your TabPages in visual mode at design-time, then control navigation from TabPage to TabPage in whatever way you think best.

You might want to "snapshot" the original Region of the TabControl in the Form 'Load event if you ever want to restore the Tabs into view.

Here's a quick example of one way to do that : a kind of "one-way" start-to-finish model :

Define a Dictionary where each Key is a TabPage, and the boolean value of each Key entry controls whether or not you will allow the user to navigate to that TabPage.

// allocate the Dictionary
Dictionary<TabPage, bool> CanNavigateDict = new Dictionary<TabPage, bool>();

You'll want to "prepare that Dictionary by doing something like this in the Form Load event :

foreach (TabPage theTPage in tabControl1.TabPages)
{
    CanNavigateDict.Add(theTPage, false); 
}

// show the first TabPage
tabControl1.SelectedTab = tabPage1;

Navigation control in this model means you need to set the boolean value of the next TabPage to 'true when, through whatever means, you've satisfied your criteria for completion of the current page: Sample

// sample of how you control navigation in the TabControl
// by using the CanNavigate Dictionary in the TabControl 'Selecting event
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
  e.Cancel = ! CanNavigateDict[e.TabPage];
}
BillW