r3nder
asked on
drawing a red border on or around a control in winforms
I want to highlight the controls that need to be filled in when a user does not enter information - for example a red border - how can I achieve this in a win form?
string msg = "";
if (comBoxToLocations.SelectedValue.ToString() != "-1" && comBoxToLocations.SelectedValue.ToString() != "3")
{
ToID = Convert.ToInt32(comBoxToLocations.SelectedValue.ToString());
}
else
{
if (comBoxToLocations.SelectedValue.ToString() == "-1")
{
msg += "You must select a location to send to\r\n";
}
if (comBoxToLocations.SelectedValue.ToString() == "3")
{
msg += "Location cannot be Unknown\r\n";
}
}
if (cmboCarrier.SelectedValue.ToString() != "-1")
{
carrierID = Convert.ToInt32(cmboCarrier.SelectedValue.ToString());
}
else
{
msg += "You must select a carrier\r\n";
}
if (string.IsNullOrEmpty(trackingNumber))
{
msg += "You must enter a tracking number\r\n";
}
if (expecteddate == today)
{
msg += "Your Expected arrival date is too short\r\n";
}
if (msg != "")
{
MessageBox.Show(msg);
return;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Tim
Glad it helps!
~Tim
~Tim
http://msdn.microsoft.com/en-us/library/aa983609(v=vs.71).aspx
You can set an initial error with:
errorProvider1.SetError(co
And clear it with:
errorProvider1.SetError(co