Danh mục

Creating a Windows Forms Application

Số trang: 8      Loại file: pdf      Dung lượng: 31.67 KB      Lượt xem: 20      Lượt tải: 0    
Hoai.2512

Phí tải xuống: 1,000 VND Tải xuống file đầy đủ (8 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tạo ra một ứng dụng Windows Forms đến nay bạn đã sử dụng Visual Studio 2005 để tạo và chạy một ứng dụng điều khiển cơ bản. Các lập trình Visual Studio 2005 môi trường cũng có chứa mọi thứ bạn cần để tạo ra các ứng dụng đồ họa Windows.
Nội dung trích xuất từ tài liệu:
Creating a Windows Forms Application Creating a Windows Forms ApplicationSo far you have used Visual Studio 2005 to create and run a basic Console application.The Visual Studio 2005 programming environment also contains everything youll needto create graphical Windows applications. You can design the form-based user interfaceof a Windows application interactively by using the Visual Designer. Visual Studio 2005then generates the program statements to implement the user interface youve designed.From this explanation, it follows that Visual Studio 2005 allows you to maintain twoviews of the application: the Design View and the Code View. The Code and Text Editorwindow (showing the program statements) doubles as the Design View window(allowing you to lay out your user interface), and you can switch between the two viewswhenever you want.In the following set of exercises, youll learn how to create a Windows program in VisualStudio 2005. This program will display a simple form containing a text box where youcan enter your name and a button that, when clicked, displays a personalized greeting in amessage box. You will use the Visual Designer to create your user interface by placingcontrols on a form; inspect the code generated by Visual Studio 2005; use the VisualDesigner to change the control properties; use the Visual Designer to resize the form;write the code to respond to a button click; and run your first Windows program.Create a Windows project in Visual Studio 2005 1. On the File menu, point to New, and then click Project. The New Project dialog box opens. 2. In the Project Types pane, click Visual C#. 3. In the Templates pane, click the Windows Application icon. 4. Ensure that the Location field refers to your My DocumentsVisual CSharp Step by StepChapter 1 folder. 5. In the Name field, type WinFormHello. 6. In the Solutions field, ensure that Create new Solution is selected. This action creates a new solution for holding the Windows application. The alternative, Add to Solution, will add the project to the TextHello solution. 7. Click OK. Visual Studio 2005 closes your current application (prompting you to save it first of necessary) and creates and displays an empty Windows form in the Design View window.In the following exercise, youll use the Visual Designer to add three controls to theWindows form and examine some of the C# code automatically generated by VisualStudio 2005 to implement these controls.Create the user interface 1. Click the Toolbox tab that appears to the left of the form in the Design View. The Toolbox appears, partially obscuring the form and displaying the various components and controls that you can place on a Windows form. 2. In the Toolbox, click the + sign by Common Controls to display a list of controls that are used by most Windows Forms applications. 3. Click Label, and then click the visible part of the form. A Label control is added to the form, and the Toolbox disappears from view. TIP If you want the Toolbox to remain visible but not hide any part of the form, click the Auto Hide button to the right in Toolbox title bar (it looks like a pin). The Toolbox appears permanently on the left side of the Visual Studio 2005 window, and the Design View shrinks to accommodate it. (You might lose a lot of space if you have a low-resolution screen.) Clicking the Auto Hide button once more causes the Toolbox to disappear again. 4. The Label control on the form is probably not exactly where you want it. You can click and drag the controls you have added to a form to reposition them. Using this technique, move the Label control so that it is positioned towards the upper-left corner of the form. (The exact placement is not critical for this application.) 5. On the View menu, click Properties Window. The Properties window appears on the right side of the screen. The Properties window allows you to set the properties for items in a project. It is context sensitive, in that it displays the properties for the currently selected item. If you click anywhere on the form displayed in the Design View, you will see that the Properties windows displays the properties for the form itself. If you click the Label control, the window displays the properties for the label instead. 6. Click the Label control on the form. In the Properties window, locate the Text property, change it from label1 to Enter your name, and then press Enter. On the form, the labels text changes to Enter Your Name. TIP By default, the properties are displayed in categories. If you prefer to display the properties in alphabetical order, click the Alphabetical button that appears above the properties list.7. Displ ...

Tài liệu được xem nhiều:

Gợi ý tài liệu liên quan: