C# question

I'm very new to C#, and I have a trivial problem that will take 10 seconds for anyone in the know. I'm trying to make an application for PocketPCs where the user enters a lot of information about himself. Because the screen is small, this has to be spread over several pages. So I made 4 forms, each with a "next" button.

I couldn't get the next button to cause a switch to the next form. In the click method for the button, I tried calling the Show method of the new form and the Hide method of the old one, but nothing happened. I have been looking at some C# tutorials but I couldn't find anything that addresses this specific problem.

not sure if this will help or not since i'm not too familiar with working with pocketPCs, but when working on .net web apps i know you can't have more then one form per page. So maybe create 4 different pages with one form on each page and have the click method redirect to the new page. Hope this helps,


Thanks. It's not a web app, though, it's a regular application.

I don't know for sure. It's been several months since I have done any programming.

Maybe something like...

private void (yourbutton)_Click(object sender, System.EventArgs e)


Form (form name) = new (form name)();

(form name).Show();

this.Visible = false;


Thanks, that worked.

For some reason, yesterday I did the same thing except I did this.Hide() instead of setting visible to false, and it didn't work, although I tried it now and it did work.

Probably somehow didn't deploy it correctly to the PocketPC emulator. Well, now I can mention my l33t .NET skills in my interview with Microsoft.

Now a slightly harder one, what if I want to have a Previous button that I can click to go back to the old page, and still have the information filled in from before.

Instead of opening up multiple forms, create one form that has mulitple same-sized panels stacked on top of each other. Then bring the current panel to the front of the screen with .BringToFront().

Yeah, do what Matt said or use the Unit of Work pattern to cache the data

Panels all the way.

To do what you want you need to separate the information you are entering in each screen from the screen code itself (separate GUI logic from Business logic if you will). Basically the way I would do this is by having a GUI mediator (mediator pattern) to control the screen creation and deletion and having individual business objects to handle the info you are entering on each screen. I just did this for a Win Forms app using C++, it can be done without too much effort.