Bài giảng Lập trình ứng dụng Windows Form in VB.NET 2005 - Buổi 4: Menu - Toolbar

™ToolStrip

™ToolStripContainer

™StatusStrip

™MenuStrip

™MenuStripContext

™NotifyIcon

pdf12 trang | Chuyên mục: Visual Basic 6.0 | Chia sẻ: dkS00TYs | Lượt xem: 2602 | Lượt tải: 2download
Tóm tắt nội dung Bài giảng Lập trình ứng dụng Windows Form in VB.NET 2005 - Buổi 4: Menu - Toolbar, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
rection: Hiển thị Text của các thành 
phần của ToolStrip theo chiều ngang 
(Horizontal), dọc theo chiều kim đồng hồ
(Vertical90, Vertical270)…
- LayoutStyle: Xác định vị trí ToolStrip theo 
chiều ngang (Horizontal), dọc (Vertical)…
- RenderMode: Xác định loại ToolStrip theo chế 
độ System, Professional…
Windows Form programming with VB.Net 2005. 4
™ Item của ToolStrip: (tiếp theo)
Item ở đây là một đối tượng thuộc 
ToolStripItem class quản lý việc thiết kế và viết 
code cho ToolStrip. Các ToolStripItem ở đây 
thường là: 
- ToolStripButton (Button)
- ToolStripLabel (Label)
- ToolStripSeparator 
- ToolStripTextBox (TextBox)
- ToolStripComboBox (Combobox)
- ToolStripDropDownButton, ToolStripSplitButton
- ToolStripProgressBar (Progressbar)
Windows Form programming with VB.Net 2005. 5
™Item as ToolStripItem 
1. Properties:
- Text: Nội dung của Item
- TextAlign: Căn lề cho Text so với ToolstripItem
- TextDirection: Text theo chiều ngang or dọc
- TextImageRelation: Quan hệ giữa Text và Image 
(chồng ghép, trên, dưới, trước, sau) 
• Overlay
• ImageAboveText
• TextAboveImage
• ImageBeforeText
• TextBeforeImage
Windows Form programming with VB.Net 2005. 6
Overlay
ImageAboveText
TextAboveImage
ImageBeforeText
TextBeforeImage
Windows Form programming with VB.Net 2005. 7
™Item as ToolStripItem (tt)
1. Properties:
- Image: image hiển thị
- ImageAlign: Căn lề cho image so với Toolstrip
- ImageTransparent: làm trong suốt màu of image
- DisplayStyle: None, Text, Image, ImageAndText
- Alignment: Định vị trái hay phải của 1 Item bên 
trái hay phải trên Toolstrip
Windows Form programming with VB.Net 2005. 8
™ToolStripContainer
Windows Form programming with VB.Net 2005. 9
™ToolStripContainer
1. Properties:
- Dock: định dạng hiển thị cho Toolstripcontainer
- LeftToolStripPanelVisible: True or False
- RightToolStripPanelVisible: True or False
- TopToolStripPanelVisible: True or False
- BottomToolStripPanelVisible: True or False
Windows Form programming with VB.Net 2005. 10
™ StatusStrip
1. Properties:
- Item: Quản lý việc thêm (Add), xóa (remove) 
các thành phần của StatusStrip
- TextDirection: Hiển thị Text của các thành 
phần của StatusStrip theo chiều ngang 
(Horizontal), dọc theo chiều kim đồng hồ
(Vertical90, Vertical270)…
- LayoutStyle: Xác định vị trí StatusStrip theo 
chuều ngang (Horizontal), dọc (Vertical)…
- RenderMode: Xác định loại StatusStrip theo 
chế độ System, Professional…
Windows Form programming with VB.Net 2005. 11
™ Item của StatusStrip: (tiếp theo)
Item ở đây là một đối tượng thuộc 
ToolStripItem class quản lý việc thiết kế và viết 
code cho StatusStrip. Các ToolStripItem ở đây 
thường là: 
- ToolStripStatusLabel (Label):
- ToolStripDropDownButton, ToolStripSplitButton
- ToolStripProgressBar (Progressbar)
StatusStrip: Chủ yếu và thường dùng là
ToolStripStatusLabel
Windows Form programming with VB.Net 2005. 12
™MenuStrip
1. Properties:
- Item: Quản lý việc thêm (Add), xóa (remove) 
các thành phần của MenuStrip
- TextDirection: Hiển thị Text của các thành 
phần của MenuStrip theo chiều ngang 
(Horizontal), dọc theo chiều kim đồng hồ
(Vertical90, Vertical270)…
- LayoutStyle: Xác định vị trí MenuStrip theo 
chuều ngang (Horizontal), dọc (Vertical)…
- RenderMode: Xác định loại MenuStrip theo 
chế độ System, Professional…
Windows Form programming with VB.Net 2005. 13
™Item as ToolStripItem 
1. Properties:
- Text: Nội dung của Item
- TextAlign: Căn lề cho Text so với Toolstrip
- TextDirection: Text theo chiều ngang or dọc
- TextImageRelation: Quan hệ giữa Text và Image 
(trên, dưới, trước, sau, chồng ghép)
- Image: image hiển thị
- ImageAlign: Căn lề cho image so với Toolstrip
- ImageTransparent: làm trong suốt màu of image
- DisplayStyle: None, Text, Image, ImageAndText
- Alignment: Định vị trái hay phải của 1 Item bên 
trái hay phải trên Toolstrip
Windows Form programming with VB.Net 2005. 14
™MenuItem as ToolStripMenuItem 
1. Properties:
- Text: Nội dung của Item
- TextAlign: Căn lề cho Text so với ToolstripMenuItem
- TextDirection: Text theo chiều ngang or dọc
- TextImageRelation: Quan hệ giữa Text và Image (trên, 
dưới, trước, sau, chồng ghép)
- Image: image hiển thị
- ImageAlign: Căn lề cho image so với ToolstripMenuItem
- ImageTransparent: làm trong suốt màu of image
- DisplayStyle: None, Text, Image, ImageAndText
- Alignment: Định vị trái hay phải của 1 Item bên trái hay 
phải trên ToolstripMenuItem
Windows Form programming with VB.Net 2005. 15
™ Item của MenuStrip: (tiếp theo)
Item ở đây là một MenuItem là đối tượng thuộc 
ToolStripMenuItem class quản lý việc thiết kế và
viết code cho MenuStrip. ToolStripMenuItem ở 
đây thường là: 
- ToolStripComboBox
- ToolStripTextBox
- ToolStripSeparator 
- DropDownItems: thuộc tính kế thừa cha con 
nghĩa là trong một MenuItem có DropDownItems 
và trong một DropDownItems có thể có
MenuItem khác… theo thứ tự phân cấp thư một 
cây thư mục
Windows Form programming with VB.Net 2005. 16
ToolStripItem Container Support 
Class ToolStrip
Menu
Strip
Status
Strip
ToolStripButton Yes No No
ToolStripComboBox Yes Yes No
ToolStripSplitButton Yes No No
ToolStripLabel Yes No No
ToolStripSeparator Yes Yes No
ToolStripDropDownButton Yes No No
ToolStripTextBox Yes Yes Yes
ToolStripMenuItem No Yes No
ToolStripStatusLabel No No Yes
ToolStripProgressBar Yes No Yes
Windows Form programming with VB.Net 2005. 17
™ToolStripMenuItem Members
1. Properties
- Checked: Kiểm tra trạng thái Checked hay không 
Checked của ToolStripMenuItem (True or False)
- ShortcutKeys: Chỉ ra shortcut key (phím tắt) khi gọi 
ToolStripMenuItem VD: Ctrl+N …
- ShowShortcutKeys: Cho phép ẩn or hiện Shortcut key
- ShortcutKeyDisplayString: nếu ShowShortcutKeys
bằng True ta có thể cho hiển thị phím tắt đảo vị trí của 
phím chức năng. Vd: Shift+Ctrl+N thay vì hiển thị
Ctrl+Shift+N
2. Event:
- CheckedChanged: Handle this event to respond when 
the item is checked or unchecked.
Windows Form programming with VB.Net 2005. 18
™ ContextMenuStrip
- Window Form có hai loại Menu là Main menu 
và Context menu. Context menu như là “Pop 
up menu” thường cung cấp cho User thực hiện 
việc right-click để thực hiện một phần tác vụ
trên Windows form. 
- Hầu hết tất cả các Control thường có thuộc tích 
ContextMenuStrip khi đối tượng đó được gán 
(Set) bằng một ContextMenuStrip được tạo và
xử lý sự kiện (Event) thực hiện việc right-click 
thì ContextMenuStrip sẽ được Display or Show
Windows Form programming with VB.Net 2005. 19
™ NotifyIcon
- Diễn tả Icon của Window Form về trạng thái 
System Tray (StaskBar) 
- NottifyIcon liên quan đến trạng thái của Window 
Form: theo đối tượng WindowState bao gồm: 
• FormWindowState.Maximized
• FormWindowState. Normal
• FormWindowState. Minimized
1. Properties:
- Icon: Icon hiển thị ở TaskBar
- ContextMenuStrip: Set ContextMenuStrip cho 
NotifyIcon
Windows Form programming with VB.Net 2005. 20
™ MaskedTextBox & RichTextBox
- MaskedTextBox & RichTextBox: có tất cả các 
Properties và Event như một TextBox và có đặc 
điểm riên sau:
- RichTextBox: tương đương một TextBox ở dạng 
MultiLine=True 
- MaskedTextBox: có Properties (thuộc tính) Mask
cho phép định dạng cách thức hiển thị và nhập 
thông tin vào theo một định dạng đã được định sẵn 
ví dụ như ngày tháng, Giờ, số, chuỗi… __/__/___ ; 
061-3876543
Windows Form programming with VB.Net 2005. 21
Windows Form programming with VB.Net 2005. 22
Windows Form programming with VB.Net 2005. 23
™ MaskedTextBox Format
element Description
0 Chỉ đư được nhập vào số, nếu không nhập vào sẽ nhận khoảng trắng 
9 nhập số hoặc khoảng trắng 
# Digit or space, optional. If this position is blank in the mask, it will be 
rendered as a space in the text property. Plus (+) and minus (-) 
signs are allowed.
L Letter, required. Restricts input to the ASCII letters a-z and A-Z. This 
mask element is equivalent to [a-zA-Z] in regular expressions. 
? Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This 
mask element is equivalent to [a-zA-Z]? in regular expressions. 
& Character, required. If the AsciiOnly property is set to true, this 
element behaves like the "L" element. 
C Character, optional. Any non-control character. If the AsciiOnly
property is set to true, this element behaves like the "?" element.
A Alphanumeric, optional. If the AsciiOnly property is set to true, the 
only characters it will accept are the ASCII letters a-z and A-Z.
a Alphanumeric, optional. If the AsciiOnly property is set to true, the 
only characters it will accept are the ASCII letters a-z and A-Z.
Windows Form programming with VB.Net 2005. 24
™ MaskedTextBox Formatelement Description
. Decimal placeholder. The actual display character used will be the 
decimal placeholder appropriate to the format provider, as determined 
by the control's FormatProvider property.
, Thousands placeholder. The actual display character used will be the 
thousands placeholder appropriate to the format provider, as 
determined by the control's FormatProvider property.
: Time separator. The actual display character used will be the time 
placeholder appropriate to the format provider, as determined by the 
control's FormatProvider property.
/ Date separator. The actual display character used will be the date 
placeholder appropriate to the format provider, as determined by the 
control's FormatProvider property.
$ Currency symbol. The actual character displayed will be the currency 
symbol appropriate to the format provider, as determined by the 
control's FormatProvider property.
< Shift down. Converts all characters that follow to lowercase. 
> Shift up. Converts all characters that follow to uppercase.
| Disable a previous shift up or shift down.
\ Escape. Escapes a mask character, turning it into a literal. "\\" is the 
escape sequence for a backslash. 

File đính kèm:

  • pdfBài giảng Lập trình ứng dụng Windows Form in VB.NET 2005 - Buổi 4_Menu - Toolbar.pdf
Tài liệu liên quan