在winform里面点一个按钮,谈出一个警告窗口,该怎么写???

解决方案 »

  1.   

    MessageBox.Show(l.Text.ToString() + "不能为空!", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
      

  2.   

    MessageBox.Show("警告内容", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
      

  3.   

     private void button1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
                {
                    MessageBox.Show("用户名或密码不能为空!");
                }
                else
                {
                    con = new SqlConnection(@"Data Source=owen\SQL2008;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=sa");
                    com = new SqlCommand("select count(*) from [user] where name='" + textBox1.Text.Trim() + "' and password='" + textBox2.Text.Trim() + "'", con);
                    con.Open();
                    int i = (int)com.ExecuteScalar();
                    con.Close();
                    if (i != 0)
                    {
                        MessageBox.Show("登陆成功!");
                    }
                    else
                    {
                        MessageBox.Show("登陆不成功!");
                    }
                }
      

  4.   

    MessageBox.Show(this, "格式不匹配!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);