我正在制作startlist,所以很明显我想防止出现具有相同起始编号的竞争对手。我有用于输入值的文本框,其中保存按钮转换为 DataGridView 表。像这样:
bool CheckFiledIsEmpty()
{
if (textStN.Text == string.Empty ||
textN.Text == string.Empty ||
textSN.Text == string.Empty ||
textC.Text == string.Empty ||
textYB.Text == string.Empty)
return false;
else
return true;
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (CheckFiledIsEmpty())
{
string Column1 = textStN.Text;
string Column2 = textN.Text;
string Column3 = textSN.Text;
string Column4 = textC.Text;
string Column5 = textYB.Text;
string[] row = { Column1, Column2, Column3, Column4, Column5 };
dataGridView1.Rows.Add(row);
textStN.Text = "";
textN.Text = "";
textSN.Text = "";
textC.Text = "";
textYB.Text = "";
}
else
{
MessageBox.Show("Input all information about competitor!");
}
}
我希望当点击SaveColumn1
按钮时,检查(start number textbox ) 中的先前值,textStN
如果有相同的值,则错误框如下:“具有该起始编号的竞争对手已经存在!”
感谢您的帮助,对不起我的英语。