Well as we all know everyones gotta start somewhere, so this tutorial is aimed to get you going with CSharp,
Get it free here -> Visual C# 2005 Express Edition
One thing i would like to say first is that because of what we are making the program in, anyone who wants to use the program will need .net framework 2.0 available here.. otherwise they will get an error.
To start a new project click found in the topleft corner.
Youll now see something like this:
These are the different types of application you can make, in this tutorial we'll be using Windows Application; so select that. On doing so you'll notice that in the textbox below the words WindowsApplication1 will come up; this will be the name of your project, as we will be making an organiser in this tutorial change it to Organiser and click OK.
The designer will now come up, this is where you can visually edit your program.
The "form" you see is your program:
You should also see the Properties window:
A Solution Explorer:
And the Error, Warning and Message lists window:
All these windows can be moved around and resized to your liking with the mouse.
You may have also noticied that each window can also be closed, if at anytime you wish to reopen a window just open the view menu at the top and select the window from the dropdown:
Saving and Distributing your program
1st of all i will tell you how to save your app, around the top-left corner you should see a little button that looks like this:
Click it and this window should appear:
The 1st box is the name of your project,
The 2nd box is the location it saves too
and the 3rd box is the name of your *solution.
* A solution is basically a list of your projects, in our app we have one project; this is quite normal as its quite rare to need more than one.
Once your happy with the information youve entered click OK to finalise the save.
Note: If is checked and the location you enter doesnt exist then it will be made.
Now whenever you wish to save just click
IN order to distribute our app we will first need to build it, this is rather easy as all you need to do is press F6 ... in order to build+debug the app press F5.
Alternatively you could enter debugging mode through the debug menu:
So now you will see your program floating there! Of course its nothing at the moment as all we've done is save it, but its a start B)
You can exit debugging mode by pressing the X on your app or through the debug menu again:
So now your program has been built, lets go get it:
Open up the folder you saved your project to -> Go into the next folder -> Bin -> Debug; here you will see your built app:
It is remade everytime you build.
Note: You wont need to worry about the other files in this folder as they're just debugging things, although if you know that your app relys on something in there you will have to remember to keep them together.
Customisation
So the icon isnt exactly totally radically huh? Well we better fix that then! Go back into c# and rightclick your projects properties in the Solution Explorer and select open:
Another page will now come up with around 10tabs on the left, for now we'll just be worrying about the 1st tab.
Just to name a few things: the Assembly Name is the name of your app and the Root Namespace is the name the project refers to the app as.
To change the icon click the button next to the icon combobox. You can now browse through your comp for a suitable icon for your app (The FastIcons download page offers some pretty good ones: http://www.fasticon.com/downloads.html)
Once chosen, save the app and build it again using F5; you can now go into the debug folder and feel awesome about your achievement :rolleyes:
You'll notice that there is a line of text under the name that is slightly faded; it is possible to change that and furthermore add another line of text under that by clickng the Assembly Information... button... we will not be getting into this though as it is beyond the scope of the tutorial and, well, not really needed.
Right, time to actually begin coding!
Ill try and make this as easy as possible: 1st off go back to your designer tab (should be on the bar of tabs near the top) and open up the toolbox by pressing (Should be around the topright)
So now a list of tools should make themselves apparent, as you can see there are loads of tools, all we will be using though is the button so click 'n' drag it onto the form:
For this tutorial we want a txt document to open up whenever we press the button, so go make a txt document called hello.txt and save it into the debug folder; now double-click the button.. welcome to the code page for form1
You should see this:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Organiser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
Code: Select all
namespace Organiser
{
Code: Select all
public partial class Form1 : Form
{
Code: Select all
public Form1()
{
InitializeComponent();
}
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
}
Code: Select all
}
}
In order to launch hello.txt when we click the button we will need to do the following:
First of all type Process within the "button1_click" brackets; you will notice as soon as you begin to type a list comes up; this is known as intellisense and lists everything you can type at that moment in time. Ignor it for now. Once youve typed Process you will notice the last s has a redline underneath it, hold your mouse over it and click the arrow that appears:
If you were to select the 1st option, the code "using System.Diagnostics;" would be added to your list of uses, the 2nd option would replace Process with "System.Diagnostics.Process".
You might be wondering what is the point in all this, well, the point is Process is a part of System.Diagnostics, and while the app can use System.Diagnostics, it wasnt using it at the time. The best course of action to take here is to choose the 1st option as, like i said before, it just makes writing code quicker as you will only have to type Process instead of System.Diagnostics.Process.
Back to coding... after Process add .Start(Application.StartupPath + "\\hello.txt"); so your code should now look like this:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace Organiser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process.Start(Application.StartupPath + "\\hello.txt");
}
}
}
Now then i'll explain what i just did:
Code: Select all
.Start
Code: Select all
(Application.StartupPath
Code: Select all
+ "\\hello.txt");
Tahts it for now , mayb more soon, until then post any questions you may have and i'll be happy to answer.