As promised a simple example. Remember that it is just a functional example and that the code isn't all how it should be. Well, that said, here is the class used to toggle the forms.
ref class ToggleForm
{
public:
ToggleForm(void)
{
current = 0;
};
void addForm(Form^ form)
{
formlist.Add(form);
};
void next(void)
{
moveToForm(1);
};
void previous(void)
{
moveToForm(-1);
};
private:
int current;
ArrayList formlist;
void moveToForm(int movement)
{
Form^ currentForm = (Form^)formlist[current];
currentForm->Visible = false;
current = (formlist.Count + current + movement) % (formlist.Count);
Form^ nextForm = (Form^)formlist[current];
nextForm->Visible = true;
};
};
In the load of the first form I create the other forms, add them to the ToggleForm class and give each a reference of toggleForm. I simply used the so called OtherForm twice but of course it can be any other form.
toggleForm = gcnew ToggleForm();
toggleForm->addForm(this);
OtherForm^ otherFormB = gcnew OtherForm;
otherFormB->Text = "B";
OtherForm^ otherFormC = gcnew OtherForm;
otherFormC->Text = "C";
toggleForm->addForm(otherFormB);
toggleForm->addForm(otherFormC);
otherFormB->toggleForm = toggleForm;
otherFormC->toggleForm = toggleForm;
The buttons on the form simply call the previous and next functions of the ToggleForm object and this handles the hiding and showing of the forms.
You can also download this simple example project at:
http://orion.woelmuis.nl/FormToggleExampleProject.zip[
^]
Well, this probably will give you enough idea about how to implement such a mechanism.
Good luck!