创建项目

创建完是这样的

打开工具箱

钉在上面

资源管理器

属性\事件

计数器
从左侧拖动需要的控件
在右侧设置控件属性
主要还是name\text
label用lblName小驼峰,lbl_name也可以
textBox用txtName
botton用btnName
点击

这个默认生成的,唯一写的一条代码就是下面这条
lblCount.Text = txtInput.Text.Length.ToString();

我的第一个计数器

点击弹窗
MessageBox.Show(txtInput.Text, "你输入的是");

返回值
private void btnOK_Click(object sender, EventArgs e)
{
if (MessageBox.Show(txtInput.Text, "你输入的是", MessageBoxButtons.YesNoCancel) == DialogResult.No )
{
lblCount.Text = "No";
}
else
{
lblCount.Text = "哈哈";
}
}
列表
string input = text_add.Text;
//添加项
listBox_name.Items.Add(input);
//删除最后一项
listBox_name.Items.RemoveAt(listBox_name.Items.Count - 1);


窗体
在资源管理器添加窗口
from.show(); //打开平行窗口
from.showDialog(); //打开一个窗口,其他窗口不能操作
网友评论