I am quite new to c#/ windows programing, and am struggling a little with windows forms...
What i want to do is to be able to display varied content in one form. For example; the form starts by displaying a splash image "welcome to ..." , then on a click will move to a list of options, say 4 buttons. Clicking this brings up a new "page" of options... etc.
Can someone point me in the right direction as to how this can be implemented?
( I am starting to suspect that i am barking up the wrong tree; i either need to create and display seperate forms... or create "clickable" icons and paint them to the form... )
Thanks in advance
Scott LyslePosted Nov 14, 2007, 9:11 AM
Well, normally you would use separate forms unless you are trying to build a dialog or some sort of wizard interface.
If you are trying to build a wizard interface, you could do it many different ways, for example, you could add a split container control to your form and change its orientation to horizontal and drag the splitter near to the bottom leaving enough room for a couple of buttons (back and forward). Add two buttons to the bottom panel, and then add one panel each for each page of your dialog to the top panel in the splitter container. Add whatever graphics and controls you need for each of the pages by adding those things to each panel. You could initialize the form to show the first page with your welcome sort of message and instructions and then you could add a little bit of code to expose and hide each panel in response to clicking the forward and back buttons.
A very simple example of this might use the following bit of code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); panel2.Visible = false; panel1.Visible = true; panel1.Dock = DockStyle.Fill; panel2.Dock = DockStyle.None; btnBack.Enabled = false; btnFwd.Enabled = true; } private void btnFwd_Click(object sender, EventArgs e) { panel2.Visible = true; panel1.Visible = false; panel1.Dock = DockStyle.None; panel2.Dock = DockStyle.Fill; btnBack.Enabled = true; btnFwd.Enabled = false; } private void btnBack_Click(object sender, EventArgs e) { panel2.Visible = false; panel1.Visible = true; panel1.Dock = DockStyle.Fill; panel2.Dock = DockStyle.None; btnBack.Enabled = false; btnFwd.Enabled = true; } } }