我正在Windows窗体上运行应用程序,在其中进行记录,但请确认是否填写了某些字段。但是,我使用的是错误提供程序,但是当我引起错误时,它们将我标记为所有人,除了DateTimePicker和必须在其中输入的文本框输入Int我的代码可以出现什么错误?
private void btnCargar_Click(object sender, EventArgs e)
{
// Method to clear the error provider (if they had already appeared before)
LimpiarErrorICono();
if (txtSalesOrderI.Text == string.Empty || txtModelo.Text == string.Empty || txtCustomer.Text == string.Empty || txtTotalI.Text == string.Empty || cmbPriorityI.Text == string.Empty
|| cmbPriorityStatus.Text == string.Empty || dtmpDateReceived.Checked)
{
this.MensajeError("Faltan Ingresar Datos");
if (txtSalesOrderI.Text == string.Empty)
{
ErrorIcono.SetError(txtSalesOrderI, "Ingrese un SalesOrder");
}
if (txtCustomer.Text == string.Empty)
{
ErrorIcono.SetError(txtCustomer, "Ingrese un Customer");
}
if(txtModelo.Text == string.Empty)
{
ErrorIcono.SetError(txtModelo, "Ingrese un Modelo");
}
// In this field it is the text box that an int must go and I don't see
the error provider when I don't enter anything
if(txtTotalI.Text == string.Empty)
{
ErrorIcono.SetError(txtTotalI, "Ingrese un Numero");
}
if(cmbPriorityI.Text == string.Empty)
{
ErrorIcono.SetError(cmbPriorityI, "Ingrese una Prioridad");
}
if (cmbPriorityStatus.Text == string.Empty)
{
ErrorIcono.SetError(cmbPriorityStatus, "Ingrese una Estatus");
}
// DateTimePicker in which I must check a date and if the error should not appear icon
if (dtmpDateReceived.Checked == false)
{
ErrorIcono.SetError(dtmpDateReceived, "Ingrese una Fecha");
}
}
要确定在文本框中输入的文本是否为int类型,可以使用方法Int32.TryParse
。