您的位置:首页 > 其它

.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
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息