如何关闭提示窗口?

时间:2013-03-01 08:00:10

标签: c# rfid

该程序正常运行。当出现提示并点击“无效的RFID”时,弹出无效的RFID消息,我可以再次扫描。但是,如果RFID被接受,我希望提示自动关闭。在此程序中,提示不是自动关闭。我必须添加什么才能使提示自动关闭?

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        string ramses = serialPort1.ReadLine();
        SetRFIDText(ramses);

    }

    private string dotRFID = "";
    private bool shouldClose = false;

    protected void SetRFIDText(string input)
    {
        this.Invoke(new Function(delegate()
        {
            string Hexed = new LasalleRFIDComputerRentals.BLL.DAL.Utils().HexIt(input);

            dotRFID = Hexed.Trim();
            txtRFID.Text = Hexed.Trim();


            if (txtRFID.Text.Trim() == "")
            {
                MessageBox.Show(this, "Please provide the member's RFID.", "Save Member Information", MessageBoxButtons.OK);
                txtRFID.Focus();
                return;
            }

            CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);
            if (customer.CustomerID <= 0)
            {
                MessageBox.Show(this, "Incorrect RFID.", "Validation", MessageBoxButtons.OK);
                return;
            }
            else
            {

                txtRFID.Text = "";



                if (_parentForm == "StandBy")
                {
                    Utils.CurrentCustomer.CustomerInfo = customer;
                    frmStandBy form = (frmStandBy)this.Owner;
                    form.xResult = "OK";
                    this.Close();

                }

            }
           }));

    }

我尝试在底部使用this.Close();form.xResult = "OK";下),但最终会挂起。救命啊!

1 个答案:

答案 0 :(得分:0)

嗯,我能够通过将This.Close();更改为This.Hide();

来使其发挥作用