让知识更加联贯 让技术走进生活
我的博客
我的程序 我的网络
------郑紫至
E-mail:zhengzizhi@yahoo.com.cn
地磅称量系统
12. MyTemplateForm窗体模板中编辑数据的操作风格代码如下:
private void button1New_Click(object sender, EventArgs e)
{
this.button1New.Enabled = false;
this.button1Modify.Enabled = false;
this.button1Delete.Enabled = false;
this.button1Query.Enabled = false;
this.button1Print.Enabled = false;
this.button1Save.Visible = true;
this.button1Cancel.Visible = true;
}
private void button1Modify_Click(object sender, EventArgs e)
{
this.button1New.Enabled = false;
this.button1Modify.Enabled = false;
this.button1Delete.Enabled = false;
this.button1Query.Enabled = false;
this.button1Print.Enabled = false;
this.button1Save.Visible = true;
this.button1Cancel.Visible = true;
}
private void button1Delete_Click(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = true;
this.button1Delete.Enabled = true;
this.button1Query.Enabled = true;
this.button1Print.Enabled = true;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
private void button1Query_Click(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = true;
this.button1Delete.Enabled = true;
this.button1Query.Enabled = true;
this.button1Print.Enabled = true;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
private void button1Print_Click(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = true;
this.button1Delete.Enabled = true;
this.button1Query.Enabled = true;
this.button1Print.Enabled = true;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
private void button1Save_Click(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = true;
this.button1Delete.Enabled = true;
this.button1Query.Enabled = true;
this.button1Print.Enabled = true;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
private void button1Cancel_Click(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = true;
this.button1Delete.Enabled = true;
this.button1Query.Enabled = true;
this.button1Print.Enabled = true;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
private void MyTemplateForm_Load(object sender, EventArgs e)
{
this.button1New.Enabled = true;
this.button1Modify.Enabled = false;
this.button1Delete.Enabled = false;
this.button1Query.Enabled = true;
this.button1Print.Enabled = false;
this.button1Save.Visible = false;
this.button1Cancel.Visible = false;
}
在设计模式下鼠标双击窗体Load事件栏位和双击7个button按钮的Click事件栏位自动生成代码
然后编写内部具体实现 。