我有一个带有 2 个复选框和 3 个按钮的表单。单击 Button3 时,程序检查是否选中了 checkbox1,如果选中,则文本框 1 的值更改为“Hello”。如果复选框 2 被选中,则值更改为“请帮助”。
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += "a";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += "b";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
If (checkBox1.Checked = true ) ;
{
textBox1.Text += ("hello ");
}
If(checkBox2.Checked = true);
{
textBox1.Text += ("hello ");
}
txtRun = new TextBox();
txtRun.Name = "txtDynamic";
txtRun.Location = new System.Drawing.Point(20, 18);
txtRun.Size = new System.Drawing.Size(200, 25);
// Add the textbox control to the form's control collection
this.Controls.Add(txtRun);
}
private void bindingNavigatorMovePreviousItem_Click(object sender, EventArgs e)
{
}
}
}