Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 39 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
39
Dung lượng
819 KB
Nội dung
Week 3
Windows Controls
Contents
MenuStrip and ContextMenuStrip control (p.147)
TreeView (p.110)
Advanced topics (p.521)
Slide 2
Create MenuStrip at run-time
Add a menu to MenuStrip control at run-time
MenuStrip.Items.Add method
Example:
MenuStrip.Items.Add("File");
MenuStrip.Items.Add("View");
Add a menu item to other menu item at run-time
ToolStripMenuItem.DropDownItems.Add method
Example:
ToolStripItem mnuOpen;
mnuOpen = fileToolStripMenuItem.DropDownItems.Add("Open");
mnuOpen.Click += new EventHandler(mnuOpen_Click);
Slide 3
ContextMenuStrip control (p.173)
ContextMenuStrip similar to the MenuStrip control
The main difference between the ContextMenuStrip
and the MenuStrip
ContextMenuStrip control does not have a top-level
menu
Not visible at run time unless invoked by right-clicking
the control that it is associated with
Slide 4
ContextMenuStrip control (cont.)
Associating a ContextMenuStrip property with a
control
Using ContextMenuStrip property of a control or
Write in Mouse_Up event handler
ContextMenuStrip1.Show(Control, X, Y)
Demo:
Module 4 – Exercise 3 (modified)
Slide 5
TreeView control (p.110)
The TreeView control
allows you to display a
list of objects in a
hierarchical manner
Node
Root
Parent Node
Child Node
Level of nodes
TreeNode object
Slide 11
TreeView properties
Nodes: gets the collection of child nodes belong to
TreeView
FullRowSelect: True/False
HideSelection: True/False
ImageList
LabelEdit: True/False
ShowLines: True/False
SelectedNode: get or set the selected node
Slide 12
TreeNode properties
Text
ImageIndex
SelectedImageIndex
IsSelected
Level
Parent
Nodes: gets the collection of child nodes belong to a
TreeNode
Slide 16
TreeNode methods
Methods Description
Expand() Expands a node
Collapse() Collapses a node
ExpandAll() Expands all the children of a node
CollapseAll() Collapses all the children of a node
GetNodeCount() Return the number of child node
Slide 17
Methods, properties of TreeView,
TreeNode
Some important methods, properties of the TreeView,
TreeNode:
.Nodes.Add( string text )
.Nodes.Add( TreeNode node )
.Nodes.Remove( TreeNode node )
.Nodes.RemoveAt( int index )
.Nodes.Clear()
.Nodes.Count
.Nodes[int index]: returns a TreeNode object
Slide 18
[...]... topics in Windows Forms MDI application (p.553) The NotifyIcon component (p.123) Drag-Drop (p.533) Self-study Using user assistance controls and components (p.573p.590) Implementing Globalization and Localization for a Windows Forms application (p.543) Deploying applications with ClickOnce (p.669) Creating setup projects for deployment (p.676) Slide 44 Using user assistance controls. .. store information you want Set Tag property for each TreeNode Slide 29 Advanced topics in Windows Forms MDI application (p.553) The NotifyIcon component (p.123) Drag-Drop (p.533) Self-study Using user assistance controls and components (p.573p.590) Implementing Globalization and Localization for a Windows Forms application (p.543) Deploying applications with ClickOnce (p.669) Creating... ClickOnce (p.669) Creating setup projects for deployment (p.676) Slide 32 MDI application (p.553) Multiple Document Interface (MDI) Windows Single Document Interface (SDI) IsMdiContainer = False Multiple Document Interface (MDI) IsMdiContainer = True Slide 33 Redisplaying child windows Find form If not existing Show If existing Activate private void HienForm( Form f ) { bool thay = false; foreach (Form . Week 3
Windows Controls
Contents
MenuStrip and ContextMenuStrip control (p.147)
TreeView