I have to do a project on geotechs, and I need at least 3 forms, but how do you make it go from one form to another?

Recommended Answers

All 4 Replies

There are various ways to skin that cat. The best approach depends a bit how you want the app to behave.

Your first/main form will be displayed automatically.
To keep that form on display in the background but force the user to use a second form, somewhere in Form1 you would need code to say:

Form2.ShowModal;

This is common where you want to pop up another window to get some info from the user before you carry on.

If you want to allow the user to use either Form1 or Form2 then you would have

Form2.Show;

This is the approach for something like a toolbox.

If you want the first form to disappear whilst the second form is shown, then use Form2.ShowModal; as above and also Form2 would need code like this:

Form1.Hide;

This is quite horrible and it is hard to think of a case where this is appropriate.If you want to do it, make sure Form2 is in the uses list of Form1's interface section and Form1 is in the uses list of Form2's implementation section (or vice versa). If you use both interface secontions or both implementation sections the compiler will give a circular reference error.

Anyway, these are the most obvious approaches. If you need something more unusual please describe the way your app should work.

Yes you descirbed exactly what i want to do. So basicly i have to trigger something that hides one form by saying Form1.hide ; and then show another by Form2.Show ; and if i want them both to show I say Form2.showmodal ;

Not exactly.

If you want both forms to show and both be usable, call Form2.Show

If you want Form2 to show and be usable and Form1 to be visible but not usable, call Form2.ShowModal.

If you want Form2 to show and be usable, and Form1 not to be visible (so obviously not usable) call Form2.ShowModal and also call Form1.Hide

Got that! Thanks! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.