| | |
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 algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml



