Lập trình trên Window cơ bản phần 8
Trang 1Lập trình trên Windows
với Microsoft® NET
Giảng viên : Hồ Hoàn Kiếm
Trang 2
SDI (1)
fj Untitled - Notepad ïÏ || xi
File Edit Format Help
Notepad allows only one docuemnt to be open at a time 4
C11 (0y voi (C
File Edit Format Help
Notepad allows only one docuemnt to be open at a time «i
An SDI
application can
-| Active Window | Basen active window sr
at a time
Trang 3
ihDœM¿3 & [à # | * Bà -;- @ >x £ 2| W @ ?
Al v =
| arial -0 +/B2lU|\E=B232?
Duter Window
(or)
Parent
Window
— |
= |
44 PM Sheet1 { Sheet2 / Sheet3 "¬ n ner Wi ndow
Child Window
Trang 4
Designing an ¬ application
IsMdiContainer = true
Trang 5
F3Microsoft Excel
| Eile Edit View Insert Format Tools Data Window Help
Activating and Deactivating Windows
iDzZN¿3 ẽlà # # Rạm ©- @z 224 010 3|
child window
— wo
wy oO a 5 SSS viNa|—|O [I ff NUMf ff
Active child window
Trang 6
Rựpes of Mendr—* (0nteI[en\
Paste
As with the control
at runtime
As in MDI form
during design
Trang 7
= Displays a menu at runtime
= MainMenu can be created in two ways:
-I|xi
1 File Edit Using the MainMenu
control, and menu designer
at design time
Creating an instance of the
MainMenu class at runtime
MainMenu myMainMenu = new MainMenu();
this.Menu = myMainMenu;
Trang 8
Menultems
S
Sh ortCut Text
PerformSelect
Index
ShowShortCut
EVENTs
Trang 9
rer
= Context menus give users access to frequently used commands by clicking the right mouse button
= Context menus are created with the help of the
ContextMenu control
oS
Trang 10
| oolBar
a GMS FSB oro Gel y Bán a "aR 9
= |t is situated immediately below the menu bar
= The buttons in a ToolBar are analogous to the items in a menu
1d ToolBar control icon
A as in TooIBox
Different button appearance options:
* DropDownButton
* Separator
* ToggleButton
Trang 11"Validate data in all the fields in the form
"Enable and Disable controls based on
user Input
Main Events
"KeyPress
*"KeyDown
"KeyUp
Trang 12[ypes of Errors
mistake in typing a keyword, missing punctuation, or an incorrectly specified variable
action
errors or run-time errors, but the results are not which were intended
Trang 13
ErrorProvider control can be used to
display an error icon when the user enters
invalid data
Properties Methods
BlinkStyle SetError
ContainerControl
Icon
Trang 14Exceptions can be handled with the help of :
catch throw final!)
aes (textB oxl Pext==
rr ¬
{
try {
throw new NullReferenceException();
}
catch (NullReferenceException)
{
MessageBox Show("Organization name cannot be empty");
textBoxl.Focus();