我想做这样一个按钮 正常显示为“打开串口” 点击一下后 ,打开com口 ,并且显示为“关闭串口”,再按一下又变为“打开串口”,同时关闭com口if(button1.enabled==true)
button1.text="关闭串口";
serialPort1.open();
else
{ if(button1.enabled==false)
button1.text="打开串口";
serialPort1.close();}
我的想法就是按钮 状态为1 或0 请问是这样吗·?
button1.text="关闭串口";
serialPort1.open();
else
{ if(button1.enabled==false)
button1.text="打开串口";
serialPort1.close();}
我的想法就是按钮 状态为1 或0 请问是这样吗·?
解决方案 »
- 求两个非常简单的转换!!!
- 关于DataGridView数据转换的问题
- 115网盘上传文件httpWebRequest怎么实现,求教高手!
- c#新手上路,掉进坑了,help me quick@@@
- 大家好,请问哪里可以找到Twain接口帮助文档(twain_32.dll),急需,谢谢!
- 今天初学C#,一调试竟发现:C#是解释型的!!!
- 求教高手啊~~~~~~~~~ 急
- 一个很烦的问题,高人请进
- 俄文显示
- 求救!!(vs.net正式版)怎样移植带crystal报表的程序到其他机器??
- AxwebBrowser.Document强制转化IHTMLDocument2无效?!
- Combobox的下拉列表区
if(button1.text == "打开串口";)
{
button1.text = "关闭串口";
serialPort1.open();
}
else
{
button1.text = "打开串口";
serialPort1.close();
}
然后建立checkBox1_CheckedChanged事件,如下: private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked)
{
this.checkBox1.Text = "打开串口";
serialPort1.Open();
}
else {
this.checkBox1.Text = "关闭串口";
serialPort1.Close();
}
}