.NET 开发从入门到精通系列课程(2)
2005-12-07 22:33
537 查看
Creating Top-Notch User Experiences With Windows Forms in Visual Studio .NET//Windows界面开发就是基于事件驱动的//wincv(class viewr) 在命令行中输入//建立新窗体,在属性中改变control的值,可以显示/隐藏(最大、小化按钮)2.1 Using Controlsn Controls represent items on a form that allow user to manipulate datan The forms designer allows you to drag and drop controlsn Can set control properties at design time to visually create the GUIn Common controls: TextBox Label ComboBox ListBox Button CheckBox RadioButtonn Other powerful controls: TreeView ListView TabControl OpenFileDialog SaveDialogPractice: Using Controls to Indicate Common User Interactionsn True/False Flag: CheckBoxn Single Choice: RadioButtons
contained in a GroupBoxn Select from a list: CheckBox, ListBox, ComboBoxn Accept/Cancel: Buttons2.2 Dialog Formsn Dialog Forms will be shown modally using Form.ShowDialog();n Synchronous block until form is closedn Clicking OK or Cancel should return different DialogResultPractice:n Form.ShowDialog()
Method returns a
DialogResult
enumeration valuen Set forms
DialogResult value
inside button click
event handler2.3 MDI Forms//多文档接口窗体n Multiple Document Interface (MDI) forms contain children forms (document/view concept)n Namesake – multiple documents (child documents) loaded at one time; one activen Children can be arranged tiled or stacked with Window menun All functionality is provided by Microsoft .NET formsPractice:n Parent: Form.IsMdiContainer propertyn Child: Form.MdiParent property2.4 Menus and Context Menus//鼠标右键事件n Use menus to organize functionsn Menu designern Add code to event hanlersn Standard menus: File Edit Helpn Context menuPracticen MainMenu controln ContextMenu control and Form.ContextMenu property2.5 Event-Driven Code: Events and Delegatesn User clicks buttonn Button invokes delegate for the eventn Delegate calls the bound eventn Click event firesn Your code written in Click event handler runsn Delegates allow multiple events (all matching signatures) to be handled by one methodn Delegates can be multicast: call multiple event handlersPractice:Event Handlers with C#Private void InitializeComponent(){... this.btGetCustomer.Click += new System.EventHandler( this.btGetCustomer_Click);...}Private void btGetCustomer_Click( object sender, System.EventArgs e){ //your code goes here ...} 2.6 Validationn Validation needs to be performed at the Control and the Form leveln ErrorProvider controln Control.CausesValidation propertyn Validating eventn Form level validation done in accept button click event
2.7 Use Whichever Language You Feel Most Productive Withn The CLR equalizes functionality of languagesn There are subtle differences between Microsoft Visual C# and Visual Basic (VB) but they’re really negligible: C# has operator overloading, unsafe code, XML Comments; VB can be more verbosen Editors have slightly different featuresn End the disagreement; accept and embrace other languages for what they aren The CLR and the framework class libraries are really what you need to learn
Session Summaryn Using .NET forms provides
9e67
for an excellent way to visually create a GUIn Controls allow you to model a UI using visual elements that are familiar to Windows usersn Writing code is easy with the event-programming model of .NETn Validation is easy to attain with the Frameworkn CLR Makes all languages equal
contained in a GroupBoxn Select from a list: CheckBox, ListBox, ComboBoxn Accept/Cancel: Buttons2.2 Dialog Formsn Dialog Forms will be shown modally using Form.ShowDialog();n Synchronous block until form is closedn Clicking OK or Cancel should return different DialogResultPractice:n Form.ShowDialog()
Method returns a
DialogResult
enumeration valuen Set forms
DialogResult value
inside button click
event handler2.3 MDI Forms//多文档接口窗体n Multiple Document Interface (MDI) forms contain children forms (document/view concept)n Namesake – multiple documents (child documents) loaded at one time; one activen Children can be arranged tiled or stacked with Window menun All functionality is provided by Microsoft .NET formsPractice:n Parent: Form.IsMdiContainer propertyn Child: Form.MdiParent property2.4 Menus and Context Menus//鼠标右键事件n Use menus to organize functionsn Menu designern Add code to event hanlersn Standard menus: File Edit Helpn Context menuPracticen MainMenu controln ContextMenu control and Form.ContextMenu property2.5 Event-Driven Code: Events and Delegatesn User clicks buttonn Button invokes delegate for the eventn Delegate calls the bound eventn Click event firesn Your code written in Click event handler runsn Delegates allow multiple events (all matching signatures) to be handled by one methodn Delegates can be multicast: call multiple event handlersPractice:Event Handlers with C#Private void InitializeComponent(){... this.btGetCustomer.Click += new System.EventHandler( this.btGetCustomer_Click);...}Private void btGetCustomer_Click( object sender, System.EventArgs e){ //your code goes here ...} 2.6 Validationn Validation needs to be performed at the Control and the Form leveln ErrorProvider controln Control.CausesValidation propertyn Validating eventn Form level validation done in accept button click event
2.7 Use Whichever Language You Feel Most Productive Withn The CLR equalizes functionality of languagesn There are subtle differences between Microsoft Visual C# and Visual Basic (VB) but they’re really negligible: C# has operator overloading, unsafe code, XML Comments; VB can be more verbosen Editors have slightly different featuresn End the disagreement; accept and embrace other languages for what they aren The CLR and the framework class libraries are really what you need to learn
Session Summaryn Using .NET forms provides
9e67
for an excellent way to visually create a GUIn Controls allow you to model a UI using visual elements that are familiar to Windows usersn Writing code is easy with the event-programming model of .NETn Validation is easy to attain with the Frameworkn CLR Makes all languages equal
相关文章推荐
- ASP.NET MVC2程序开发入门到精通系列课程 下载
- 一起谈.NET技术,MSDN Webcast:ASP.NET MVC2程序开发入门到精通系列课程
- ASP.NET MVC2程序开发入门到精通系列课程[收藏]
- .NET 开发从入门到精通系列课程(1):
- ASP.NET MVC2程序开发入门到精通系列课程
- .NET开发从入门到精通系列课程
- ASP.NET MVC2程序开发入门到精通系列课程
- ASP.NET MVC2程序开发入门到精通系列课程01
- [MSDN Webcast]Windows Embedded从入门到精通系列课程(18):用模拟器零成本体验MF开发
- [推荐]ASP.NET 2.0 快速入门系列课程(附代码示例)[WMV]
- [导入]ASP.NET MVC框架开发系列课程(5):控制器(Controller)以及Action.zip(25.35 MB)
- Visual Studio 2008开发新特性系列课程(3):VS2008新特性之LINQ入门
- jQuery 1.3 for Asp.Net、 CSLA.Net 3.6 for Windows 及 MOSS/WSS 一步一步从入门到精通三个系列的目录
- Hypermesh网格划分从入门到精通系列课程
- ASP.NET MVC框架开发系列课程(8):AJAX
- 老赵 MSDN Webcast ASP.NET MVC框架开发系列课程
- ASP.NET MVC框架开发系列课程
- 北风网web开发资深讲师李炎恢出品--ASP系列课程从入门到精通
- Android开发书籍推荐:从入门到精通系列学习路线书籍介绍
- Android官方开发文档Training系列课程中文版:构建第一款安卓应用之入门指南