Checkbox Trong Lập Trình C# Winform | How Kteam
Dẫn nhập
Sức mạnh của hệ điều hành Window là không thể chối cãi. Và để tạo nên sức mạnh đó không thể thiếu những ứng dụng mạnh mẽ. Vậy để tạo ra những ứng dụng đó, người lập trình viên cần học cái gì?
Cùng nhau tìm hiểu serial Lập trình Winform.
Nội dung
Form1.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CheckboxGUI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox1_Click(object sender, EventArgs e) { //MessageBox.Show("Click"); } private void checkBox1_CheckedChanged(object sender, EventArgs e) { //MessageBox.Show("CheckedChanged"); } private void checkBox1_CheckStateChanged(object sender, EventArgs e) { //MessageBox.Show("CheckStateChanged"); } private void btnClick_Click(object sender, EventArgs e) { string name = txbName.Text; string kter = ckbKter.CheckState == CheckState.Checked ? "là" : ckbKter.CheckState == CheckState.Unchecked ? "không phải" : "phải cũng không phải là"; string showString = string.Format("Chào bạn {0}, bạn {1} kter!", name, kter); MessageBox.Show(showString); } } }Form1.Designer.cs
namespace CheckboxGUI { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.ckbKter = new System.Windows.Forms.CheckBox(); this.btnClick = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.txbName = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // ckbKter // this.ckbKter.AutoSize = true; this.ckbKter.Location = new System.Drawing.Point(37, 86); this.ckbKter.Name = "ckbKter"; this.ckbKter.Size = new System.Drawing.Size(116, 17); this.ckbKter.TabIndex = 0; this.ckbKter.Text = "Bạn có phải là Kter"; this.ckbKter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.ckbKter.ThreeState = true; this.ckbKter.UseVisualStyleBackColor = true; this.ckbKter.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); this.ckbKter.CheckStateChanged += new System.EventHandler(this.checkBox1_CheckStateChanged); this.ckbKter.Click += new System.EventHandler(this.checkBox1_Click); // // btnClick // this.btnClick.Location = new System.Drawing.Point(37, 121); this.btnClick.Name = "btnClick"; this.btnClick.Size = new System.Drawing.Size(75, 23); this.btnClick.TabIndex = 1; this.btnClick.Text = "Click"; this.btnClick.UseVisualStyleBackColor = true; this.btnClick.Click += new System.EventHandler(this.btnClick_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(34, 44); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(47, 13); this.label1.TabIndex = 2; this.label1.Text = "Tên bạn"; // // txbName // this.txbName.Location = new System.Drawing.Point(37, 60); this.txbName.Name = "txbName"; this.txbName.Size = new System.Drawing.Size(100, 20); this.txbName.TabIndex = 3; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 261); this.Controls.Add(this.txbName); this.Controls.Add(this.label1); this.Controls.Add(this.btnClick); this.Controls.Add(this.ckbKter); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.CheckBox ckbKter; private System.Windows.Forms.Button btnClick; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox txbName; } }Download project
Kết luận
Bài sau chúng ta sẽ cùng tìm hiểu về Messagebox trong lập trình C# Winform.
Cảm ơn các bạn đã theo dõi bài viết. Hãy để lại bình luận hoặc góp ý của mình để phát triển bài viết tốt hơn. Đừng quên “Luyện tập – Thử thách – Không ngại khó”.
Tải xuống
Tài liệu
Nhằm phục vụ mục đích học tập Offline của cộng đồng, Kteam hỗ trợ tính năng lưu trữ nội dung bài học Checkbox trong lập trình C# Winform dưới dạng file PDF trong link bên dưới.
Ngoài ra, bạn cũng có thể tìm thấy các tài liệu được đóng góp từ cộng đồng ở mục TÀI LIỆU trên thư viện Howkteam.com
Đừng quên like và share để ủng hộ Kteam và tác giả nhé!
Thảo luận
Nếu bạn có bất kỳ khó khăn hay thắc mắc gì về khóa học, đừng ngần ngại đặt câu hỏi trong phần BÌNH LUẬN bên dưới hoặc trong mục HỎI & ĐÁP trên thư viện Howkteam.com để nhận được sự hỗ trợ từ cộng đồng.
CỘNG ĐỒNG HỎI ĐÁP HOWKTEAM.COM
GROUP THẢO LUẬN FACEBOOK Từ khóa » Checkbox Trong C# Là Gì
-
[C#] Hướng Dẫn Sử Dụng CheckBoxes
-
Checkbox - RadioButton Trong Lập Trình C# Winforms
-
Sự Kiện CheckedChanged CheckBox Trong C# Winforms
-
[Bài 07] - RadioButton Và CheckBox Trong C# | Lập Trình Cuộc Sống
-
Top 14 Checkbox Trong C# Là Gì
-
CheckBox.CheckedChanged Event (System.Windows.Forms)
-
Bài Tập C#.NET - Bài 3 - Sử Dụng Checkbox - RadioButton Trong Lập ...
-
Xử Lý Sự Kiện Checkbox C
-
[C# Winform] Hướng Dẫn Sử Dụng 3 Trạng Thái Của Checkbox
-
Phần 1: Form Và Các Control Thông Dụng | Tìm ở đây
-
CheckBox Control - The Complete WPF Tutorial
-
CheckBox Trong C - Thư Viện WinForm
-
Các Control Trên Toolbox Trong C#.NET - Tin Học 88