| | |
using multiple sourcefiles
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 47
Reputation:
Solved Threads: 0
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?
Anybody have any ideas? Questions are good too of course!
Thanks for reading!
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?

Anybody have any ideas? Questions are good too of course!
Thanks for reading!
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();
Now in your main form put the following code in a button click event:
ExtraForm.Show();
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Apr 2008
Posts: 45
Reputation:
Solved Threads: 10
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.
•
•
Join Date: Jul 2008
Posts: 47
Reputation:
Solved Threads: 0
•
•
•
•
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.
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.
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Jul 2008
Posts: 47
Reputation:
Solved Threads: 0
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:
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!
What I needed was to know how to access another windows form file (BMI.cs).
I did this using:
C# Syntax (Toggle Plain Text)
BMI classBMI = new BMI();

The .Show() and .Hide() were what I needed, so no additions there.
Thread solved I'd say.
Thanks for the help all!
![]() |
Other Threads in the C# Forum
- Previous Thread: LINQ question
- Next Thread: Int32 to float
Views: 640 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






