Add a check for the Enabled property:
if ((myControl.GetType() == typeof(TextBox)) || (myControl.GetType() == typeof(ComboBox)))
{
if (myControl.Enabled && string.IsNullOrWhiteSpace(myControl.Text))
{
MessageBox.Show(myControl.Name.Substring(3).ToString() + " is ");
myControl.Focus();
return true;
}
myControl.Text = TrimBetween(myControl.Text);
}
BTW: I have removed the Trim, and changed the check - if you use the IsNullOrWhiteSpace method it does that for you.