Lập Trình Cơ Sở Dữ Liệu Với CSharp- P13
Số trang: 10
Loại file: pdf
Dung lượng: 794.41 KB
Lượt xem: 16
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used.
Nội dung trích xuất từ tài liệu:
Lập Trình Cơ Sở Dữ Liệu Với CSharp- P13private System.Windows.Forms.Label myLabel;private System.Windows.Forms.Button myButton;/// /// Required designer variable./// private System.ComponentModel.Container components = null;public Form1(){ // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call //}/// /// Clean up any resources being used./// protected override void Dispose(bool disposing){ if(disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing);}#region Windows Form Designer generated code/// /// Required method for Designer support - do not modify/// the contents of this method with the code editor./// private void InitializeComponent(){ this.myLabel = new System.Windows.Forms.Label(); this.myButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // myLabel // this.myLabel.Location = new System.Drawing.Point(8, 8); this.myLabel.Name = myLabel; this.myLabel.Size = new System.Drawing.Size(288, 184); this.myLabel.TabIndex = 0; this.myLabel.Text = label1; // // myButton // this.myButton.Location = new System.Drawing.Point(120, 200); this.myButton.Name = myButton; this.myButton.Size = new System.Drawing.Size(72, 24); this.myButton.TabIndex = 1; this.myButton.Text = Press Me!; this.myButton.Click += new System.EventHandler(this.myButton_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(304, 237); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.myButton, this.myLabel}); this.Name = Form1; this.Text = My Form; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void myButton_Click(object sender, System.EventArgs e) { myLabel.Text = Is this a dagger which I see before me, + The handle toward my hand? Come, let me clutch thee. + I have thee not, and yet I see thee still. + Art thou not, fatal vision, sensible + To feeling as to sight? or art thou but + A dagger of the mind, a false creation, + Proceeding from the heat-oppressed brain?; } } }Như bạn có thể thấy, lớp Form1 được bắt nguồn từ lớp System.Windows.Forms.Form . Lớp Form đại diện chomột form Windows. Ghi chú: Không gian tên System.Windows.Forms chứa nhiều lớp khác nhau để tạo ra những ứng dụng Windows. Hầu hết những lớp trong namespace này được bắt nguồn từ lớp System.Windows.Forms.Control; lớp này cung cấp chức năng cơ bản cho những điều khiển bạn có thể đặt trên một form.Lớp Form1 khai báo hai đối tượng riêng (Private) có tên myLabel và myButton, chúng là những điều khiểnnhãn và nút bạn thêm vào form của bạn trước đó. Vì đối tượng myLabel và myButton là riêng (Private), Đâycó nghĩa là chúng chỉ có thể tiếp cận trong lớp Form1.Access modifiers (những từ bổ nghĩa truy cập) cho phép bạn chỉ rõ mức độ mà với mức đó một thành viên củalớp có thể truy cập từ bên ngoài lớp. Bạn cũng có thể sử dụng một Access modifiers để chỉ rõ mức độ mà vớimức đó chính lớp này có thể dược truy cập.Bảng 6.1 cho thấy rằng những từ bổ nghĩa truy cập trong trật tự giảm dần tính khả truy cập: Public có tính khảtruy cập nhất, và Private có tính khả truy cập kém nhất.Bảng 6.1: những từ bổ nghĩa truy cậpACCESS MODIFIER ACCESSIBILITY(từ bổ nghĩa truy cập) (khả năng truy cập)public Thành viên có thể truy cập lớp này không hạn chế.protected internal Chỉ những thành viên bên trong lớp, thành viên một lớp dẫn xuất hay lớp trong cùng chương trình (hay assembly) có thể truy cập lớp này.internal Chỉ những thành viên bên trong lớp hay thành viên của lớp trong cùng chương trình (hay assembly) có thể truy cập.protect ...
Nội dung trích xuất từ tài liệu:
Lập Trình Cơ Sở Dữ Liệu Với CSharp- P13private System.Windows.Forms.Label myLabel;private System.Windows.Forms.Button myButton;/// /// Required designer variable./// private System.ComponentModel.Container components = null;public Form1(){ // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call //}/// /// Clean up any resources being used./// protected override void Dispose(bool disposing){ if(disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing);}#region Windows Form Designer generated code/// /// Required method for Designer support - do not modify/// the contents of this method with the code editor./// private void InitializeComponent(){ this.myLabel = new System.Windows.Forms.Label(); this.myButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // myLabel // this.myLabel.Location = new System.Drawing.Point(8, 8); this.myLabel.Name = myLabel; this.myLabel.Size = new System.Drawing.Size(288, 184); this.myLabel.TabIndex = 0; this.myLabel.Text = label1; // // myButton // this.myButton.Location = new System.Drawing.Point(120, 200); this.myButton.Name = myButton; this.myButton.Size = new System.Drawing.Size(72, 24); this.myButton.TabIndex = 1; this.myButton.Text = Press Me!; this.myButton.Click += new System.EventHandler(this.myButton_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(304, 237); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.myButton, this.myLabel}); this.Name = Form1; this.Text = My Form; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void myButton_Click(object sender, System.EventArgs e) { myLabel.Text = Is this a dagger which I see before me, + The handle toward my hand? Come, let me clutch thee. + I have thee not, and yet I see thee still. + Art thou not, fatal vision, sensible + To feeling as to sight? or art thou but + A dagger of the mind, a false creation, + Proceeding from the heat-oppressed brain?; } } }Như bạn có thể thấy, lớp Form1 được bắt nguồn từ lớp System.Windows.Forms.Form . Lớp Form đại diện chomột form Windows. Ghi chú: Không gian tên System.Windows.Forms chứa nhiều lớp khác nhau để tạo ra những ứng dụng Windows. Hầu hết những lớp trong namespace này được bắt nguồn từ lớp System.Windows.Forms.Control; lớp này cung cấp chức năng cơ bản cho những điều khiển bạn có thể đặt trên một form.Lớp Form1 khai báo hai đối tượng riêng (Private) có tên myLabel và myButton, chúng là những điều khiểnnhãn và nút bạn thêm vào form của bạn trước đó. Vì đối tượng myLabel và myButton là riêng (Private), Đâycó nghĩa là chúng chỉ có thể tiếp cận trong lớp Form1.Access modifiers (những từ bổ nghĩa truy cập) cho phép bạn chỉ rõ mức độ mà với mức đó một thành viên củalớp có thể truy cập từ bên ngoài lớp. Bạn cũng có thể sử dụng một Access modifiers để chỉ rõ mức độ mà vớimức đó chính lớp này có thể dược truy cập.Bảng 6.1 cho thấy rằng những từ bổ nghĩa truy cập trong trật tự giảm dần tính khả truy cập: Public có tính khảtruy cập nhất, và Private có tính khả truy cập kém nhất.Bảng 6.1: những từ bổ nghĩa truy cậpACCESS MODIFIER ACCESSIBILITY(từ bổ nghĩa truy cập) (khả năng truy cập)public Thành viên có thể truy cập lớp này không hạn chế.protected internal Chỉ những thành viên bên trong lớp, thành viên một lớp dẫn xuất hay lớp trong cùng chương trình (hay assembly) có thể truy cập lớp này.internal Chỉ những thành viên bên trong lớp hay thành viên của lớp trong cùng chương trình (hay assembly) có thể truy cập.protect ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật lập trình mẹo lập trình Giáo trình lập trình C lập trình C for Winform Lập trình sự kiện ngôn ngữ lập trình CTài liệu liên quan:
-
Thủ thuật giúp giải phóng dung lượng ổ cứng
4 trang 217 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 209 0 0 -
101 trang 200 1 0
-
Hướng dẫn lập trình với Android part 4
5 trang 156 0 0 -
Tìm hiểu về ngôn ngữ lập trình C: Phần 1 - Quách Tuấn Ngọc
211 trang 149 0 0 -
142 trang 130 0 0
-
161 trang 130 1 0
-
Giáo trình Vi điều khiển PIC: Phần 1
119 trang 117 0 0 -
Bài giảng Phương pháp lập trình: Chương 9 - GV. Từ Thị Xuân Hiền
36 trang 112 0 0 -
150 trang 104 0 0