Just for start we will create very simple program, just for describing the basis of Windows Forms programming in C#.
We are using the newest version of Visual Studio, Visual Studio 2008 for programming environtment. In it is implemented the .Net Framework 3.5, but we can make projects under .Net 2.0, 3.0 and 3.5.
So, let start.
Start your Visual Studio, and in the menus go to File -> New -> Project (Ctrl+Shift+N). Then in the dialog box under the Project Types tree view select C# -> Windows, and on the right choose Windows Forms Application. Then fill the needed informations Name and Location. Then click OK.

After clicking OK, the project will be created. You will get a windows form with dimensions 300x300 pixels.
Move the cursor above the toolbox, drag one Button control and drop it on the form. You can change it's name by selecting Properties from it's context menu and change the property Text. In the properties you can find many customizations.
Double click on the button, the editor will create a Click event from the Button, and you will see code from the main form and the code from the button1 click event.
private void button1_Click(object sender, EventArgs e) { }
Then add this code between the brackets
MessageBox.Show("Hi there.\n"+ "This is a Windows Forms Application Sample!", "Sample Message");
Now debug the application. You can do that by pressing F5.
The application will start running, click the button and the message box will pop up.

Close the message box, close the application.
This was really easy right?
If you don't understand something, please comment here...








{ 1 trackback }