说明:Channel_Number位本代码所定义的一个变量
private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox2.Text == "")
textBox2.Text = 0.ToString();
int Channel_Number = int.Parse(textBox2.Text.ToString()); //用于将输入的数字转换为整数
textBox2.Text = Channel_Number.ToString();
if(Channel_Number==0 || Channel_Number<= 15) //此处最好能够结合所读取文本数据有多少列
{
return;
}
else
{
MessageBox.Show("请输入0-15范围内的整数");
return;
}
}