| | |
Getting basic with Visual Studio in C#
Please support our C# advertiser: Intel Parallel Studio Home
Visual Studio is a great tool to use. But for beginners like me a few years back, it was a bit overwhelming and confusing. You got the feeling you lost all the control. VS has it’s special ways of doing things with partial classes and so on.
So lets get back in control (for a while) this has the drawback we have to do a lot of things for ourself. But it’s fun to do it once and in the future we will enjoy the benefits that VS offers even more.
So lets begin with a new project by clicking File->New Project in the dialog that opens click Empty Project and give it a name. Click OK. What you see now is a bit different from the usual Console- or Form Application. You should see practically nothing, emptyness all over!
So lets start filling that in. Rightclick your project in the solutions explorer and select Add New Item…In the dialog that appears select Code File and give it a name if you want to. Click the Add button. Paste the code snippet in or type it in. Or start with a very basic
public class MyWindow : Form
{
}
Run it and see what happens…Build it up line per line from here. Experiment like hell, it’s very instructive! Enjoy the learning. Don’t forget to fill in the References map with the necessary dll’s in the solution explorer by right clicking it and selecting Add Reference…, .
So lets get back in control (for a while) this has the drawback we have to do a lot of things for ourself. But it’s fun to do it once and in the future we will enjoy the benefits that VS offers even more.
So lets begin with a new project by clicking File->New Project in the dialog that opens click Empty Project and give it a name. Click OK. What you see now is a bit different from the usual Console- or Form Application. You should see practically nothing, emptyness all over!
So lets start filling that in. Rightclick your project in the solutions explorer and select Add New Item…In the dialog that appears select Code File and give it a name if you want to. Click the Add button. Paste the code snippet in or type it in. Or start with a very basic
public class MyWindow : Form
{
}
Run it and see what happens…Build it up line per line from here. Experiment like hell, it’s very instructive! Enjoy the learning. Don’t forget to fill in the References map with the necessary dll’s in the solution explorer by right clicking it and selecting Add Reference…, .
using System; using System.Windows.Forms; using System.Drawing; public class MyWindow : Form //derive a class MyWindow from a Form class { Button MyButton = new Button(); //make a new button TextBox MyTextBox = new TextBox(); //make a new textbox public MyWindow() //constructor { //=================================================================== //set some properties of this MyWindow form this.Text = "Just testing"; this.BackColor = Color.DeepSkyBlue; //=================================================================== //set location,size and text of the newly created button on the form MyButton.Location = new Point(100, 100); MyButton.Size = new Size(50, 50); MyButton.Text = "Do it"; //hook in a routine to handle click events for MyButton MyButton.Click += new EventHandler(MyButton_Click); //add the control to the MyWindows forms control collection this.Controls.Add(MyButton); //=================================================================== //set location,size and text of the newly created textbox on the form MyTextBox.Location = new Point(10, 10); MyTextBox.Size = new Size(150, 20); MyTextBox.Text = ""; //add the control to the MyWindows forms control collection this.Controls.Add(MyTextBox); //=================================================================== } private void MyButton_Click(object Obj, EventArgs EvA) { //aarghh the ultimate //by clicking on our button, set a text in a textbox this.MyTextBox.Text = "Hello world!"; } private static void Main() { Application.Run(new MyWindow()); //start the application } }
Similar Threads
- Visual Web developer express Vs Visual studio express edition (ASP.NET)
- Help !! visual studio or Sql mangament studio (C#)
- Visual Studio 6.0 or Visual Studio .Net 2003? (Windows Software)
- Visual Studio 6.0 or Visual Studio .Net 2003 (C++)
- The Move.....Visual Basic 6, Visual Basic .NET ? (VB.NET)
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox robot save saving serialization server sleep socket sockets sql sql-server statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml



