Lecture Windows programming: Chapter 3(2) - Châu Thị Bảo Hà
Thông tin tài liệu:
Nội dung trích xuất từ tài liệu:
Lecture Windows programming: Chapter 3(2) - Châu Thị Bảo Hà Chapter 3 WindowsProgramming Cont’d 1 Contents• Introduction to Windows Form Application• Introduction to Form• Introduction to Control• Events• Some common Controls• Some advanced Controls Slide 2 Naming rules• Each control has an identifier (Name property) – can contain letters, digits, and underscores (_) – cannot start with digits – can start with the @ symbol – no spaces or punctuation marks• If multiple words capitalize 1st letter of each word• 3 letter lowercase prefix identifies control type Slide 3 Recommended namingObject Class Prefix ExampleForm frm frmDataEntryButton btn btnExitTextBox txt txtPaymentAmountLabel lbl lblTotalRadioButton rad radBoldCheckBox chk chkPrintSummaryPictureBox pic picLandscapeComboBox cbo cboBookListListBox lst lstIndegredientsGroupBox grb grbColor Slide 4 Some common Controls1. Button2. Label, LinkLabel3. TextBox ( + ErrorProvider component), RichTextBox4. GroupBox, Panel5. CheckBox, RadioButton6. PictureBox, ImageList7. ListBox, CheckedListBox8. ComboBox Slide 5 Button (p.453)• Allows the user to click it to perform an action – some properties: • FlatStyle • Image • ImageAlign • Text • TextAlign – default event: • Click event: happens whenever a user clicks the button Slide 6 Label (p.456)• To display text or images that cannot be edited by the user – some properties: • AutoSize • BorderStyle • Font • Image • ImageAlign • Text • TextAlign Slide 7 LinkLabel (p.456)• To add Web-style links to applications – some properties: • ActiveLinkColor • LinkArea • LinkColor • LinkVisited • VisitedLinkColor Slide 8 TextBox (p.457)• To enter text or display information – some properties: • CausesValidation: true/false • CharacterCasing: Normal/Upper/Lower • MaxLength • Multiline: true/false • PasswordChar • ReadOnly: true/false • ScrollBars • WordWrap: true/false Slide 9 TextBox (cont.) – some events: • TextChanged • Enter • Leave These events occur in this order • Validating • Validated KeyDown and KeyUp receive the key code • KeyDown corresponding to the key that was pressed. KeyPress receives the character corresponding to a • KeyPress keyboard key. • KeyUp• Try it out - Working with a TextBox Slide Control 10 The ErrorProvider component• You can display an error to alert the user about invalid data input by using ErrorProvider component • BlinkRate property • BlinkStyle property • ContainerControl property • GetError() method • Icon property • SetError() method • SetIconAlignment() method • SetIconPadding() method Slide11 Demo: Validating and Validated event • Example:private void txtNumber1_Validating(object sender, CancelEventArgse) { if (Convert.ToInt32(txtNumber1.Text) < 0) { e.Cancel = true; // cancel the event errorProvider1.SetError(txtNumber1, “this is not a valid number); txtNumber1.SelectAll(); }}private void txtNumber1_Validated(object sender, EventArgs e) { errorProvider1.SetError(txtNumber1, ); Slide12Demo: Validating and Validated event Slide 13Demo: KeyPress event Slide 14 RichTextBox (p.470)• Used for displaying, entering, and manipulating text with more formatting (display fonts, colors, and links; load text and embedded images from a file; undo and redo editing operations; and find specified characters) – some properties (p.471): • SelectedText • SelectionAlignment • SelectionColor • SelectionFont Slide 15 GroupBox, Panel• Arrange components on a GUI – GroupBox can display a caption (p.466) • Text property: determines its caption – Panel can have scrollbar • AutoScroll property • BorderStyle property ...
Tìm kiếm tài liệu theo từ khóa liên quan:
Lecture Windows programming Lập trình Windows Bài giảng Lập trình Windows Windows programming Some common controlsTài liệu liên quan:
-
Bài tập lập trình Windows dùng C# - Bài thực hành
13 trang 186 0 0 -
bảo mật mạng các phương thức giả mạo địa chỉ IP fake IP
13 trang 159 0 0 -
Bài giảng Lập trình Windows Form với C#: Chương 3 - Lê Thị Ngọc Hạnh
11 trang 152 0 0 -
information technology outsourcing transactions process strategies and contracts 2nd ed phần 3
65 trang 111 0 0 -
Excel add in development in c and c phần 9
0 trang 110 0 0 -
Giáo trình Lập trình Windows 1 - Trường CĐN Đà Lạt
117 trang 96 0 0 -
Hướng dẫn lập trình OpenGL căn bản
33 trang 53 0 0 -
The CISA Prep Guide Mastering the Certified Information Systems Auditor Exam phần 1
60 trang 43 0 0 -
thủ thuật windows XP hay nhất phần 2
14 trang 42 0 0 -
Bài giảng Lập trình Windows nâng cao: ADO.NET - Bùi Công Danh
57 trang 38 0 0 -
Bài giảng Lập trình Windows Form với C#: Chương 1 - Lê Thị Ngọc Hạnh
56 trang 35 0 0 -
Báo cáo nghiên cứu khoa học: Nghiên cứu phần mềm bãi giữ xe thông minh
37 trang 34 0 0 -
257 trang 34 0 0
-
Bài giảng Lập trình Windows: Bài 1 - Trần Ngọc Bảo
77 trang 31 0 0 -
The CISSP Prep Guide, Second Edition Mastering the CISSP and ISSEP Exams phần 6
106 trang 30 0 0 -
SSL and TLS Essentials Securing the Web phần 7
21 trang 29 0 0 -
hướng dẫn sử dụng Rhino Ceros phần 6
12 trang 29 0 0 -
cryptography for developers PHẦN 1
45 trang 28 0 0 -
accounting reference desktop 2002 phần 6
64 trang 28 0 0 -
LightWave 3D 8 Texturing phần 7
51 trang 27 0 0