private void btnCreate_Click(object sender, EventArgs e) { foreach (Control ctr in panelSN.Controls) { if (ctr.Enabled == true) { UserModuleSN moduleSN = ctr as UserModuleSN; if (moduleSN.GetText().Trim() == "") { MessageBox.Show(this, $"灯板{moduleSN.Tag.ToString()}时间码不能为空"); return; } if (moduleSN.GetText().Trim().IsNumber() == false || moduleSN.GetText().Trim().Length != 17) { MessageBox.Show(this, $"灯板{moduleSN.Tag.ToString()}时间码格式错误"); return; } } } this.DialogResult = DialogResult.OK; //this.Close(); return; }