如上图所示布局 双击查看写代码: string bornyear = textBox1.Text.Substring(6, 4); int id; if (int.TryParse(bornyear, out id)) { if (DateTime.Now.Year - id > 18) { pictureBox1.Visible = true; } else { MessageBox.Show("年龄太小不能查看"); pictureBox1.Visible = false; } } else { MessageBox.Show("非法身份证数据"); return; }