1. Trang chủ
  2. » Giáo Dục - Đào Tạo

LẬP TRÌNH WINDOWS FORM (NGÔN NGỮ lập TRÌNH 2 SLIDE)

112 30 0

Đ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

Cấu trúc

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

  • Slide 21

  • Slide 22

  • Slide 23

  • Slide 24

  • Slide 25

  • Slide 26

  • Slide 27

  • Slide 28

  • Slide 29

  • Slide 30

  • Slide 31

  • Slide 32

  • Slide 33

  • Slide 34

  • Slide 35

  • Slide 36

  • Slide 37

  • Slide 38

  • Slide 39

  • Slide 40

  • Slide 41

  • Slide 42

  • Slide 43

  • Slide 44

  • Slide 45

  • Slide 46

  • Slide 47

  • Slide 48

  • Slide 49

  • Slide 50

  • Slide 51

  • Slide 52

  • Slide 53

  • Slide 54

  • Slide 55

  • Slide 56

  • Slide 57

  • Slide 58

  • Slide 59

  • Slide 60

  • Slide 61

  • Slide 62

  • Slide 63

  • Slide 64

  • Slide 65

  • Slide 66

  • Slide 67

  • Slide 68

  • Slide 69

  • Slide 70

  • Slide 71

  • Slide 72

  • Slide 73

  • Slide 74

  • Slide 75

  • Slide 76

  • Slide 77

  • Slide 78

  • Slide 79

  • Slide 80

  • Slide 81

  • Slide 82

  • Slide 83

  • Slide 84

  • Slide 85

  • Slide 86

  • Slide 87

  • Slide 88

  • Slide 89

  • Slide 90

  • Slide 91

  • Slide 92

  • Slide 93

  • Slide 94

  • Slide 95

  • Slide 96

  • Slide 97

  • Slide 98

  • Slide 99

  • Slide 100

  • Slide 101

  • Slide 102

  • Slide 103

  • Slide 104

  • Slide 105

  • Slide 106

  • Slide 107

  • Slide 108

  • Slide 109

  • Slide 110

  • Slide 111

  • Slide 112

Nội dung

NGƠN NGƠN NGỮ NGỮ LẬP LẬP TRÌNH TRÌNH 22 Chương 4: Lập trình windows form Bộ mơn CNPM – Khoa CNTT NGƠN NGƠN NGỮ NGỮ LẬP LẬP TRÌNH TRÌNH 22 Nội dung I Các kiến thức chung lập trình windows form II Các điều khiển thơng dụng • Label, LinkLabel, Textbox, Button, Checkbox, CheckboxList, RadioButton, PictureBox Bitmap, Lớp Application, Panel, Splitter, MenuStrip, ContextMenuStrip, StatusStrip, ToolStrip, ToolStripContainer III Các điều khiển nâng cao • Ứng dụng MDI • Tạo xử dụng UserControl NGÔN NGÔN NGỮ NGỮ LẬP LẬP TRÌNH TRÌNH 22 Tài liệu tham khảo 2010 - Tập 1; 2010 - Tập 2; 2010 - Tập 3; 2010 - Tập 4; Phạm Hữu Khang, Nhà xuất bản: Nxb Lao động Xã hội, 2010 Các giải pháp lập trình , Nguyễn Ngọc Bình Phương, Thái Thanh Phong, Nhà xuất Giao thông vận tải, 2010 Windows Forms Programming With , Erik Brown, Manning, 2010 Teach Yourself the Language in 21 days, Dradley L Jones, 2010 Website: • http://www.codeproject.com/?cat=3 (), • https://code.visualstudio.com/Docs/languages/csharp LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM I Các kiến thức chung lập trình windows form Sự kiện Lập trình hướng kiện Lập trình windows form LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Sự kiện Sự kiện kiểu tín hiệu cho chương trình biết có điều xảy Tín hiệu phát sinh tác động từ bên ngồi người dùng giống di chuyển chuột, click chuột, nhấn chuột, sinh hệ điều hành (OS), chẳng hạn đếm thời gian (Timer) Ví dụ: Nhấn phím bàn phím Nhấp chuột trái, phải, double click Di chuyển chuột … LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Sự kiện Các thành phần giao diện có khả đáp ứng lại kiện Chẳng hạn nhấp chuột vào button, lúc button nhận biết kiện này; hay textbox nhận biết kiện bàn phím tác động lên Một ứng dụng Windows thường thực nhờ vào việc đáp ứng lại kiện người dùng Mơ hình kiện Windows: LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Lập trình hướng kiện Lập trình kiện: Các thành phần giao diện có khả nhận biết kiện từ phía người dùng Tuy nhiên khả đáp ứng lại kiện thực người lập trình Khi thành phần giao diện sử dụng, người lập trình phải xác định xác hành động thành phần giao diện để đáp ứng lại kiện cụ thể Lúc người lập trình phải viết đoạn mã lệnh mà đoạn mã lệnh thực thi kiện xảy LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Lập trình hướng kiện (tiếp)  Ví dụ: ứng dụng Paint Windows; người sử dụng nhấp chuột vào nút vẽ hình elip sau dùng chuột vẽ cửa sổ vẽ, hình elip vẽ  Trong lập trình kiện, ứng dụng xây dựng chuỗi đáp ứng lại kiện Tất hành động ứng dụng đáp ứng lại kiện Do người lập trình cần phải xác định hành động cần thiết ứng dụng; phân loại chúng; sau viết đoạn mã lệnh tương ứng LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Lập trình windows form Thiết kế sử dụng Form Các thuộc tính Các phương thức Các kiện LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Thiết kế sử dụng Form Chương trình ứng dụng giao tiếp với người dùng thông qua biểu mẫu (hay gọi cửa sổ, xuất phát từ chữ Form hay Windows); Khái niệm form Cấu trúc chung Form: Các điều khiển (Control) đặt lên bên giúp cho biểu mẫu thực công việc Biểu mẫu cửa số lập trình nhằm hiển thị liệu nhận thơng tin từ phía người dùng 10 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM StatusStrip giống ToolStrip, thùng chứa (container), cần phải thêm điều khiển khác chẳng hạn như: StatusLabel, ProgressBar, DropDownButton, SplitButton Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 98 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Một cách khác để thêm điều khiển vào StatusStrip sử dụng thuộc tính Items Khi click vào thuộc tính Items, cửa sổ thiết kế xuất hình sau: Bộ mơn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 99 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Sau thiết kế, thu trạng thái với nhiều trạng thái chức phong phú, hiển thị nhiều thông tin tương tác với người dùng Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 100 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Điều khiển TreeView sử dụng để hiển thị biểu diễn dạng items giống cách truy cập đến files folders Windows Explorer Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 101 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Một số thuộc tính TreeView: S.N Property Description BackColor Gets or sets the background color for the control BackgroundImage Gets or set the background image for the TreeView control BackgroundImageLa Gets or sets the layout of the background image for the TreeView yout control BorderStyle Gets or sets the border style of the tree view control CheckBoxes Gets or sets a value indicating whether check boxes are displayed next to the tree nodes in the tree view control DataBindings Gets the data bindings for the control Font Gets or sets the font of the text displayed by the control Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 102 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM S.N Method Name & Description CollapseAll Collapses all the nodes including all child nodes in the tree view control ExpandAll Expands all the nodes GetNodeAt Gets the node at the specified location GetNodeCount Gets the number of tree nodes Sort  Sorts all the items in the tree view control ToString  Returns a string containing the name of the control Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 103 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Một số kiện lớp TreeView: S.N Event Description AfterCheck Occurs after the tree node check box is checked AfterCollapse Occurs after the tree node is collapsed AfterExpand Occurs after the tree node is expanded AfterSelect Occurs after the tree node is selected BeforeCheck Occurs before the tree node check box is checked BeforeCollapse Occurs before the tree node is collapsed BeforeExpand Occurs before the tree node is expanded Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 104 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Lớp TreeNode biểu diễn cho Node TreeView Mỗi node TreeView đối tượng thuộc lớp TreeNode Một vài thuộc tính TreeNode: S.N Property Description Name Gets or sets the name of the tree node NextNode Gets the next sibling tree node Nodes Gets the collection of TreeNode objects assigned to the current tree node Parent Gets the parent tree node of the current tree node PrevNode Gets the previous sibling tree node Tag Gets or sets the object that contains data about the tree node Text Gets or sets the text displayed in the label of the tree node TreeView Gets the parent tree view that the tree node is assigned to Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 105 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Một vài phương thức TreeNode: S.N Method Name & Description Collapse Collapses the tree node Expand Expands the tree node ExpandAll Expands all the child tree nodes GetNodeCount Returns the number of child tree nodes Remove  Removes the current tree node from the tree view control Toggle Toggles the tree node to either the expanded or collapsed state ToString  Returns a string that represents the current object Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 106 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM ImageList Khái niệm Điều khiển ImageList tập hợp Icons hình ảnh (images) lưu trữ theo dạng danh sách truy cập theo Iconsindex hặc images phải có cỡ kiểu Có nghĩa tập hợp hình thành tập icons có kích thước 16x16, 32x32, 48x48 ảnh bitmaps có kích thước Bộ mơn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 107 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Điều khiển ListView sử dụng để hiển thị danh sách items Cùng với điều khiển TreeView, cho phép tạo giao diện giống với Windows Explorer Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 108 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM S.N Property Description Alignment Gets or sets the alignment of items in the control AutoArrange Gets or sets whether icons are automatically kept arranged BackColor Gets or sets the background color CheckBoxes Gets or sets a value indicating whether a check box appears next to each item in the control CheckedIndices Gets the indexes of the currently checked items in the control CheckedItems Gets the currently checked items in the control Columns Gets the collection of all column headers that appear in the control Items Gets a collection containing all items in the control Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 109 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM S.N Method Name & Description Clear  Removes all items from the ListView control ToString  Returns a string containing the string representation of the control Sự kiện S.N Event Description ColumnClick Occurs when a column header is clicked ItemCheck Occurs when an item in the control is checked or unchecked SelectedIndexChan Occurs when the selected index is changed ged TextChanged Occurs when the Text property is changed Bộ môn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 110 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM  Ví dụ ListView Bộ mơn CNPM – Khoa CNTT Contact: huunoidq@gmail.com 111 ... https://code.visualstudio.com/Docs/languages/csharp LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM I Các kiến thức chung lập trình windows form Sự kiện Lập trình hướng kiện Lập trình windows form LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM... số lập trình nhằm hiển thị liệu nhận thơng tin từ phía người dùng 10 11 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM 12 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM 13 LẬP LẬP TRÌNH TRÌNH WINDOWS. .. ErrorControl CheckedListBox 21 22 LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM LẬP LẬP TRÌNH TRÌNH WINDOWS WINDOWS FORM FORM Một thành phần quan trọng Windows Form Web Form điều khiển Chúng sử

Ngày đăng: 29/03/2021, 12:37

TỪ KHÓA LIÊN QUAN

w