Windows Programming 2

49 139 0
Windows Programming 2

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Windows Programming Exam Midterm (Lab), Final (Lab), Project (Lab), Final test (mutiple choice test) Textbook Microsoft Net Framework 2.0 Windows-based Client Development Training Kit - MCTS - 70-526 VS 2005 – VS 2008 SQL server 2005 – 2008 (Express) PLAN Week Content Review, Forms and properties (1234,11,12) Forms & Control & Interface (1234,11,12) Forms & Control & Interface (1234,11,12) Forms & Control & Interface (1234,11,12) Working with Database (5678) Working with Database (5678) Working with Database (5678) Working with Database (5678) Working with Database (5678) 10 Multi – tier architech 11 Deployment,Report,Review subject (15) Review Button properties Accept – Default, DialogResult Textbox: autocomplete Dynamic adding controls Listbox / Combo Multiselect W1.0 Review – Properties (p56) Adjust control with Layout toolbar W1.0 Review – Properties (p52) Document Outline Window To move controls To remove a control To add a control W1.0 Review – Properties (p59) W1.0 Review – Properties Button control (p67) - properties Demo W1.0 Review – Properties Button control (p67): Mouse events Demo W1.0 Review – Properties Textbox control (p79) Demo W1.0 Review – Properties Label control Using with Textbox Alt key Focus on textbox Next TabIndex value Demo W1.0 Review – Properties LinkLabel control Like label control The LinkLabel control allows you to create a Webstyle link in your form that opens a Web page or performs some other action when clicked The LinkLabel control contains a variety of properties that allow you to configure the LinkLabel control Table 2-5 shows important properties of the LinkLabel control Demo W1.0 Review – Properties MaskTextbox control is a modified TextBox Allows to define a preset pattern for accepting or rejecting user input The Mask property allows you to specify required or optional characters, or specify whether input characters are letters or numbers, and apply formatting for the display of strings Important properties of the MaskedTextBox are shown in Table 2-7 W1.0 Review – Properties Mask property Chapter Lesson 1: Windows Forms and the User Interface Lesson 2: Managing Control Layout with Container Controls Content Form property Create a non-rectangular form 1.Form property See Table 1-1 Some Properties of the Form Class page 7-8 See new properties (unknow) 1.Form property 1.Form property Exercise Page 18-19 10 Create a non-rectangular form For advanced visual effects non-rectangular form Change Region property in Form_Load event represents an area of the screen Base on graphicspath Create a non-rectangular form A GraphicsPath represents a series of connected lines and curves A GraphicsPath may be composed of any number of figures, like ellipse Applications use paths to draw outlines of shapes Using System.Drawing class, base on GDI+ Choose Graphics programming Example: draw path on form 11 The Nodes.Add Method To use this form of the method, you must first declare and initialize a TreeNode object: Dim nodeObj As New TreeNode nodeObj.Text = “Tree Node” TreeView1.Nodes.Add(nodeObj) The Nodes.Add Method The last overloaded form of the Add method allows you to specify the index in the current Nodes collection, where the node will be added: newNode = Nodes.Add(index, nodeObj) The nodeObj Node object must be initialized as usual The Add method inserts the new node into the current Nodes collection 36 The Nodes.Add Method To add a child node to the root node, use a statement like the following: TreeView1.Nodes(0).Nodes.Add(“Asia”) To add a infomation under Asia, use a statement like the following: TreeView1.Nodes(0).Nodes(1).Nodes.Add(“Japan”) Page 112 Exer: build treeview at runtime (using code) 37 TreeNode Properties Checked In d ic a te s w h e th e r th e T r e e N o d e is c h e c k e d ( C h e c k B o x e s p ro p e r ty m u s t b e s e t to T r u e in p a re n t T r e e V i e w ) FirstNode S p e c ifie s th e fir s t n o d e in th e N o d e s c o lle c tio n ( i.e , firs t c h ild in tre e ) FullPath In d ic a te s th e p a th o f th e n o d e , s ta rtin g a t th e ro o t o f th e tr e e ImageIndex S p e c ifie s th e in d e x o f th e im a g e s h o w n w h e n th e n o d e is d e s e le c te d LastNode S p e c ifie s th e la s t n o d e in th e N o d e s c o lle c tio n ( i.e , la s t c h ild in tre e ) NextNode N e x t s ib lin g n o d e Nodes T h e c o lle c tio n o f T r e e N o d e s c o n ta in e d in th e c u rr e n t n o d e (i.e , a ll t h e c h ild re n o f th e c u rr e n t n o d e ) C o n ta in s m e t h o d s A d d (a d d s a T r e e N o d e o b je c t) , C l e a r ( d e le te s th e e n tire c o lle c tio n ) a n d R e m o v e ( d e le te s a s p e c ific n o d e ) R e m o v in g a p a re n t n o d e d e le te s a ll its c h ild re n PrevNode In d ic a te s th e p r e v io u s s ib lin g n o d e SelectedImageIndex S p e c ifie s th e in d e x o f th e im a g e to u s e w h e n th e n o d e is s e le c te d Text S p e c ifie s th e T r e e V i e w ’ s te x t Parent Collapse C o lla p s e s a n o d e Expand E xp a nd s a no d e EnsureVisible ExpandAll E x p a n d s a ll t h e c h ild re n o f a n o d e GetNodeCount R e tu r n s th e n u m b e r o f c h ild n o d e s C o m m o n M e th o d s Fig IsVisible T r e e N o d e p ro p e rt ie s a n d m e t h o d s Adding icon for Treenode Using ImageList like Listview Set property for each Treenode ImageIndex SelectedImageIndex Exercise: 38 Exer2:List contact with TreeView Save list contact to text file when exit click Init_TreeView ( ) Private Sub Init_TreeView() Dim i As Integer tre ame.ImageList = ilsBook tre ame.SelectedImageIndex = tre ame.ImageIndex = tre ame.Sorted = True For i = 65 To 90 tre ame odes.Add(Chr(i)) ext End Sub 39 AddName_To_TreeView() Private Sub AddName_To_TreeView() If txtFistName.Text "" Then strLetter = UCase(txtFistName.Text.Substring(0, 1)) intIndex = Asc(strLetter) - 65 strName = txtFistName.Text & ", " & txtLastName.Text tre ame odes(intIndex) odes.Add(str ame) _ ImageIndex = Call ClearText() End If End Sub Using Treeview Expanding and Collapsing Nodes Remove Node Search and Selecte node Level of Treenode 40 1.Expanding and Collapsing Nodes Expand and Collapse methods of Node Treeview1.Nodes(0).Expand Expand all node Using recursion Example Write program to expand collapse all node 2.Remove Nodes The Clear Method TreeView1.Nodes(0).Nodes(2).Nodes(1).Nodes.Clear The Item Property The expression Nodes.Item(1) is equivalent to the expression Nodes(1) The Remove Method Nodes.Remove(index) TreeView1.SelectedNode.Remove The SeletedNode, FullPath, PathSeparator The FirstNode, NextNode, PrevNode, and LastNode Properties 41 3.Search and select node Loop all node using recursion EnsureVisible for seleted treenode Demo 4.Level of Treenode Find Level of Tree using tag Using Parent property (treeview in small space) Using recursive function Using Custom TreeNode Using Tag property Set tag property for each TreeNode Mark treenode by tag, base on level Sync Between Treeview & ListView 42 4.Level of Treenode: example E1 Data from memory E2 Data from text file E3 Display group listview Chapter 3: Nummeric updown control (page 113) Using to set a range of numbers 43 Chapter Lesson 1: ToolStrips Lesson 2: ContextMenu Lesson 3: Mouse and keyboard Events 44 Chapter 4.1 Toolstrip Build Toolbar Adding Tool Strip Items to a Tool Strip ToolStripLabel ToolStripButton ToolStripSeparator ToolStripComboBox ToolStripTextBox ToolStripProgressBar Chapter 4.1 Toolstrip Image in toolstrip control 45 Ex Lab 1: Creating a ToolStrip–Based Web Browser - page 156 4.2 ContextMenuStrip Control Adding and Removing Context Menu Items Associating a ContextMenuStrip Property with a Control Example Using with NotyfyIcon 46 4.4 Keyboard – Mouse Events Table 4-8 Common Events Raised by Controls Mouse Events (page 184) Click and DoubleClick Mouse Movement Events 47 Keyboard events KeyDown KeyPress KeyUp EX Lab 3: Practice with Mouse Events Page 191 48 Ex Vi t chương trình di chuy n m t Picture Form s d ng phím đ nh hư ng: , , , Khi b m Enter, Picture đư c di chuy n góc trái c a Form Khi b m Space Bar, Picture đư c di chuy n góc ph i c a Form Ex Vi t chương trình luy n t p s d ng chu t: Picture hi n th ng u nhiên chương trình th i gian nh t đ nh (kho ng giây) n u ngư i chơi b m trúng Picture phím m c ng thêm 1, n u khơng trúng m đư c tr 49 Ex: ContextMenuStrip Muitipe control Vi t chương trình n p đ ng đ i tư ng sau: Chương trình hi n th c a s có textbox dùng đ nh p s ph n t (Ph i ki m tra tính h p l c a d li u nh p vào) Khi b m nút nh p, chương trình s n p đ ng button v i s lư ng tương ng v a nh p vào Khi ngư i s d ng b m chu t ph i m i button, hi n th menu dùng đ ki m tra s ch n s l hình v Các menu n u ch n s hi n th k t qu ki m tra h p tho i Khi ngưòi s d ng b m nút “ki m tra h p s ”, s h p s s hi n th d u hi u cho bi t s h p s hình bên dư i (hình dư i có tính ch t g i ý) 50 ... lvi.SubItems.Add("Col 2C1"); lvi.SubItems.Add("Col 3C1"); lvi = Items.Add("B Item2"); lvi.SubItems.Add("Col 2B2"); lvi.SubItems.Add("Col 3B2"); lvi = Items.Add("A Item3"); lvi.SubItems.Add("Col 2A3"); Exercise... Exercise:Lab: Practice with Container Controls Lab 1: Page 40- 42 Lab 2: Practice Configuring Controls, page 64 FixedPanel property 19 Chapter Advanced Windows Forms Controls Lesson Creating and Configuring... Litem As New ListViewItem Litem.Text = “TH0 02? ?? Litem.SubItems.Add(“Nguyen Van An”) Litem.SubItems.Add(“091.8 42. 577”) lvwSinhVien.Items.Add(Litem) 25 Listview Example Using the following code:

Ngày đăng: 13/05/2014, 12:19

Tài liệu cùng người dùng

Tài liệu liên quan