Textbox Trong Lập Trình C# Winform | How Kteam
Có thể bạn quan tâm
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 TextboxGUI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { } private void txbValue_TextChanged(object sender, EventArgs e) { int num = 0; if (Int32.TryParse(txbValue.Text, out num)) lbValue.Text = (num * num).ToString(); else lbValue.Text = "Vui lòng nhập số!"; } } }Form1.Designer.cs
namespace TextboxGUI { 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.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.lbValue = new System.Windows.Forms.Label(); this.txbValue = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(35, 39); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.textBox1.Size = new System.Drawing.Size(100, 130); this.textBox1.TabIndex = 0; // // textBox2 // this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textBox2.Enabled = false; this.textBox2.Location = new System.Drawing.Point(161, 39); this.textBox2.Name = "textBox2"; this.textBox2.PasswordChar = '9'; this.textBox2.RightToLeft = System.Windows.Forms.RightToLeft.No; this.textBox2.Size = new System.Drawing.Size(100, 13); this.textBox2.TabIndex = 1; this.textBox2.Text = "howkteam.com"; // // lbValue // this.lbValue.AutoSize = true; this.lbValue.Location = new System.Drawing.Point(32, 220); this.lbValue.Name = "lbValue"; this.lbValue.Size = new System.Drawing.Size(35, 13); this.lbValue.TabIndex = 2; this.lbValue.Text = "label1"; // // txbValue // this.txbValue.Location = new System.Drawing.Point(35, 186); this.txbValue.Name = "txbValue"; this.txbValue.Size = new System.Drawing.Size(100, 20); this.txbValue.TabIndex = 0; this.txbValue.TextChanged += new System.EventHandler(this.txbValue_TextChanged); // // button1 // this.button1.Location = new System.Drawing.Point(141, 184); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AcceptButton = this.button1; 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.button1); this.Controls.Add(this.txbValue); this.Controls.Add(this.lbValue); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label lbValue; private System.Windows.Forms.TextBox txbValue; private System.Windows.Forms.Button button1; } }Download project
Kết luận
Bài sau chúng ta sẽ cùng tìm hiểu về Checkbox 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 Textbox 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 » Khóa Textbox Trong C#
-
Code Không Cho Phép Sửa Textbox Trên Form | Giải Pháp Excel
-
Xin Hỏi Cách Làm ẩn, Hiện Các Text Box
-
[C#] Hướng Dẫn Tạo Textbox Chỉ Hiển Thị Số
-
Cách Dùng Label - Button - Textbox Trong C# Winforms - Freetuts
-
Để Khoá Một TextBox Trên Form Không Cho Người Dùng Nhập Vào ...
-
Create A Read-Only Text Box - Windows Forms .NET Framework
-
How To Write In C# Code To Lock A Text Box - MSDN - Microsoft
-
Chỉ Cho Phép Nhập Số Vào Textbox Trong Lập Trình C# - Blog Cá Nhân
-
[Lập Trình C# Winform] - Bài 5: Textbox| HowKteam - YouTube
-
How To Disable Textbox From Editing? - Stack Overflow
-
Đặt TextBox Là Không Thể Chỉnh Sửa - HelpEx
-
Hướng Dẫn Cách Làm Chìm Chữ Trong TextBox - YouTube
-
Cách Khóa Text Box Trong Word
-
Textbox Trong C - Thư Viện WinForm