0

通常我会这样做来检查:

            if (sp.IsOpen)
            {
                return;
            }
            else MessageBox.Show("Please open COM port.", "Status",   MessageBoxButtons.OK, MessageBoxIcon.Error);

但是我的winform中有很多按钮。大约20个按键,每个按键在发射前需要检查COM口是否打开。

唯一的方法是在每个按钮中添加上述编码吗?

还是有一次性的方法?

4

0 回答 0