Danh mục

Windows Forms

Số trang: 0      Loại file: pdf      Dung lượng: 165.74 KB      Lượt xem: 16      Lượt tải: 0    
Jamona

Phí lưu trữ: miễn phí Tải xuống file đầy đủ (0 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:

Windows Forms Overview about describe the structure of a Windows Forms application (application entry point, forms, components and controls); Introduce deployment over networks. It provides about Visual Studio, Application Structure, Form border; Form properties.
Nội dung trích xuất từ tài liệu:
Windows FormsWindows FormsOverview• Describe the structure of a Windows Forms application – application entry point – forms – components and controls• Introduce deployment over networks 2Windows Forms• Windows Forms are classes for building UIs – forms, controls, dialogs, etc. – part of the .NET Framework Library – core classes in System.Windows.Forms namespace• Possible uses include: – stand-alone Windows applications – web services front-ends – intranet “smart clients” 3Visual Studio• Visual Studio .NET provides development environment – starter templates, drag-and-drop editing, property grid, etc. 4Application Structure• Windows Forms application has three main pieces – the application itself – forms in the application – controls and components on the forms Label Application myForm Hello, World! mainForm label1 button1 Button OK 5Application• Application class represents the application itself – Run method processes UI events delivered by Windows – provides access to application environment ExecutablePath, CommonAppDataPath, UserAppDataPath, etc. – no instances, all members are static class MyApp { public static void Main() { MyForm form = new MyForm();start application Application.Run(form); } } 6 Form • Form class represents window, provides appropriate services – properties: Size, Location, Controls, ShowInTaskbar – methods: Show, Close, SetDesktopLocation – events: Load, Click, Closing • Common to derive from Form to create custom formdefine custom form class MyForm : Form { public MyForm() { this.ShowInTaskbar = false; set properties this.Location = new Point(10, 10); this.Size = new Size(100, 100); } } 7Form border• Forms can look like windows, dialogs, or tools – controlled using FormBorderStyle property – set ShowInTaskbar property to false for tool windows – window border styles show the icon from the Icon property 8 Form properties • Form has many properties – used to customize appearance and behavior public class Form : ContainerControl { public IButtonControl AcceptButton { get; set; } public IButtonControl CancelButton { get; set; } public bool HelpButton { get; set; } public Icon Icon { get; set; } public String Text { get; set; } public Size MaximumSize { get; set; }properties public Size MinimumSize { get; set; } public MainMenu Menu { get; set; } public bool ShowInTaskbar { get; set; } public FormBorderStyle FormBorderStyle { get; set; } ... } 9 Form as container • Form manages a list of controls – stored in Controls collection propertyall forms inherit class MyForm : FormControls collection { Button button1 = new Button(); Label label1 = new Label (); public MyForm() { ... this.Controls.Add(button1); add to collection this.Controls.Add(label1 ); } ... } myForm Controls button1 label1 10Form layout• Form determines layout for controls it manages – recalculates as needed, such as when user resizes form – tries to accommodate control preferences for size and location – uses Anchor and ...

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