zoukankan      html  css  js  c++  java
  • MessageBox

     private void validateUserEntry2()
        {

            // Checks the value of the text.

            if(serverName.Text.Length == 0)
            {

                // Initializes the variables to pass to the MessageBox.Show method.

                string message = "You did not enter a server name. Cancel this operation?";
                string caption = "No Server Name Specified";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;

                // Displays the MessageBox.

                result = MessageBox.Show(this, message, caption, buttons,
                    MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.RightAlign);

                if(result == DialogResult.Yes)
                {

                    // Closes the parent form.

                    this.Close();

                }

            }





    C#]
    protected void button1_Click(object sender, System.EventArgs e) {
       if(textBox1.Text == "") {
          MessageBox.Show("You must enter a name.", "Name Entry Error",
             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
       }
       else {
          // Code to act on the data entered would go here.
       }
    }
  • 相关阅读:
    第二次作业循环语句
    c语言01次作业分支,顺序结构
    PAT 1027. Colors in Mars
    PAT 1026 Table Tennis
    PAT 1035 Password
    PAT 1038. Recover the Smallest Number
    PAT 1028 List Sorting (25)
    PAT 1041 Be Unique (20)
    PAT 1025 PAT Ranking
    1037. Magic Coupon
  • 原文地址:https://www.cnblogs.com/VirtualMJ/p/MessageBox.html
Copyright © 2011-2022 走看看