1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11 namespace test1 12 { 13 public partial class Form1 : Form 14 { 15 public Form1() 16 { 17 InitializeComponent(); 18 } 19 20 private void Form1_Load(object sender, EventArgs e) 21 { 22 23 } 24 25 private void btn_Click(object sender, EventArgs e) 26 { 27 //如果点击取消 28 if (MessageBox.Show(txt.Text, "嘿嘿", MessageBoxButtons.OKCancel) == DialogResult.Cancel) 29 { 30 MessageBox.Show("拜"); 31 } 32 else MessageBox.Show("哦呼"); 33 } 34 //数输入数据的长度 35 private void txt_TextChanged(object sender, EventArgs e) 36 { 37 lab2.Text = txt.Text.Count().ToString(); 38 } 39 } 40 }