News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

The C# Integrated Development Environment

Started by OmMuruga, Jan 26, 2009, 05:42 PM

Previous topic - Next topic

OmMuruga


You should now see something like Figure 1 - 7 on your screen. Figure 1 - 7 shows you where you ' ll be spending a lot of your programming time as you read this book. It ' s called the Integrated Development Environment, or IDE, because virtually every programming tool you need to write C# programs is available to you there.

The C# Integrated Development Environment

            Back in the Dark Ages of programming, you had to load and run a programming editor to write the program ' s source code. Next, you had to close the editor and load the language compiler program to check the program ' s statements for errors. Then you had to load an assembler program to convert the source code to assembly language. Finally, you had to load and run a linker program to combine all the elements of your program into an executable program. The Visual Studio IDE provides all of these functions within a single program. This makes it much easier to write and test the programs you create.

The Major IDE Windows The IDE shown in  divides the screen into three windows. The left window shows the Visual Studio Toolbox, which, by default, shows some of the objects Visual Studio makes available to you.
             
             If you look closely you can see that the Toolbox presents a smorgasbord of objects you can use in your programs, including textboxes, labels, buttons, and other controls you will find useful as you develop your programs.
            The middle window is referred to as the Source window and currently shows an unadorned Visual Studio form object. As presented in Figure 1 - 7 , the form has no other objects placed on it . . . yet. That is, you haven ' t added any other objects (such as textboxes or buttons) from the Toolbox onto the form.
          The right side of the IDE currently shows two subwindows. The subwindow on top shows the Solution Explorer. Simply stated, the Solution Explorer shows the current development state of your project. It shows the forms the program has and its references, plus other information

          Below the Solution Explorer window is the Properties window. The purpose of the Properties window is to show you the properties associated with the object currently in focus in the Source window. If you look closely at the form in the Source window in Figure  you ' ll notice that it has a couple of small white boxes along its edge. These are called sizing boxes and their purpose is to enable you to alter the size of the objects to which they are attached. However, the sizing boxes also show which object in the Source window currently has the attention, or focus , of Visual Studio. Whatever object has the focus in the Source window is also the object that the Properties window displays. In Figure the properties shown in the Properties window apply to the form shown in the Source window. Visual Studio always maintains this relationship between the object in focus in the Source window and the information displayed in the Properties window.

Using the Source Code Window

                   If you click Form1.cs in the Solution Explorer window, you can move to the Solution Explorer menu bar and click the source code icon to view the code that Visual Studio has written for you thus far.the location of the source code icon in the Solution Explorer window. (When you hover the cursor over the source code icon a small textbox opens and displays the words " View Code, "
          The code associated with clicking the source code icon shown in Figure 1 - 8 is shown in Figure  When you click the source code icon, notice that another tab is added at the top of the Source window. One tab has form1.cs (Design) on it, while the other tab has form1.cs. The first tab is for the view of the form in the design mode. (The design mode is shown in Figure 1 - 7 .) The second tab is the source code mode and shows you the code for the program under development. Even though you haven ' t written any code yourself, Visual Studio has already written some for you behind your back! You can see the TestProgram C# source code in Figure

It ' s not necessary that you understand the code shown in Figure 1 - 9 at this time. All you ' re trying to do at this point is write a very short program to see if the installation was done correctly. However, you will be spending a lot of time in the source code window as you write your own programs.

Adding an Object to a Windows Form

A form with nothing on it isn ' t terribly interesting. Let ' s change the form so that, when the program runs, it displays the message, " My first program. " You need to add a label to the form object shown in the Source window in Figure  to hold your program message. There are two ways to add a label object to a form. First, as shown in Figure 1 - 10 , you can click the label object in the Toolbox and, while holding the left mouse button down, drag the label over to the form and release the mouse button.

           Second, you can simply double - click the label object in the Toolbox. The mouse double - click causes Visual Studio to place a label object near the upper left - hand corner of the form shown in the Source window. You can click the label in the Source window while holding the left mouse button down and drag the label to wherever you want it to appear on the form object. When you have positioned the label object where you want it on the form, simply release the mouse button. :acumen :acumen