Form1.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. namespace WindowsFormsPanel
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void Form1_Load(object sender, EventArgs e)
  19. {
  20. panel1.Visible = false;
  21. richTextBox1.Text = "姓名:唐僧\n性别:男\n年龄:27\n名族:汗\n职业:和尚";
  22. }
  23. private void button1_Click(object sender, EventArgs e)
  24. {
  25. if (textBox1.Text == "") {
  26. MessageBox.Show("请输出姓名");
  27. textBox1.Focus();
  28. }
  29. else
  30. {
  31. if(textBox1.Text.Trim() == "唐僧")
  32. {
  33. panel1.Show();
  34. }
  35. else
  36. {
  37. MessageBox.Show("查无此人");
  38. textBox1.Text = "";
  39. }
  40. }
  41. }
  42. }
  43. }