Hello all! I have yet another question.

Since I'm making good progress in learning C# I'd like to learn some new stuff that I have been putting off and to clean up my code.

As such it seemed like a good idea to try and create a frontend for a program, in the way that you start the program, are presented with a bunch of buttons, and when you press one of the buttons it runs a specific file of code.

In a live example:
I would like to create a general calculationsprogram. It can calculate your BMI, from metric to imperial, between hexadecimal/binairy/decimal, stuff like that. When the program is run it greets you with a little choicescreen asking you what you want to calculate and stuff. For example: you press the BMI button and it hides the welcomescreen and loads the BMI part of the program.

No I'm not sure if I can use a class to load something like that. I would also like to split the program up in parts, so the BMI part has its own sourcefile.

Am I making any sense? :P

Anybody have any ideas? Questions are good too of course!

Thanks for reading!

Recommended Answers

All 5 Replies

In your project solution explorer window right click the bold name and add a new Windows form. Fill it with what you want. Say it is called ExtraForm.
Now in your main form put the following code in a button click event:
ExtraForm.Show();

To answer you questions about the different source files, if you're using Visual Studio, each time you add a new component to your solution (as explained by ddanbe above), it is placed in its own physical code file in your solution's directory. So if you had 10 forms, you would expect to see 10 different source files that each contain one of your forms.

To answer you questions about the different source files, if you're using Visual Studio, each time you add a new component to your solution (as explained by ddanbe above), it is placed in its own physical code file in your solution's directory. So if you had 10 forms, you would expect to see 10 different source files that each contain one of your forms.

This is indeed essentialy what I want, and I did know how to add components. I.. just don't know how to access them...

Say that I have the normal form1.cs file, and I add a BMI.cs file and write that file as though it was a single screen application. What command do I use for the button in form1 to access/load my BMI.cs code?

As for ddanbe, thanks for the hint on the .Show! I'm guessing .Hide hides the form until recalled?

Thanks for the help so far!

bcasp filled in something I forgot. Thanks!
Your guess on the Hide is right.
You make fields in the BMI form class you can acces (use property syntax) in your form1 class. (Assume you intantiated the BMI class via new) then you can use BMI.Myproperty; or do things like BMI.Myproperty = 123; etc.

To finish off this thread I'll add this:

What I needed was to know how to access another windows form file (BMI.cs).
I did this using:

BMI classBMI = new BMI();

and later I could access classBMI just like my BMI.cs file ;)

The .Show() and .Hide() were what I needed, so no additions there.

Thread solved I'd say.

Thanks for the help all!

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.