How many times we have written such code to enable/disable controls, based on some conditions:
if (string.IsNullOrEmpty(textBoxFind.Text))
{
buttonFindNext.Enabled = false;
buttonReplace.Enabled = false;
buttonReplaceAll.Enabled = false;
}
else
{
buttonFindNext.Enabled = true;
if (string.IsNullOrEmpty(textBoxReplace.Text))
{
buttonReplace.Enabled = false;
buttonReplaceAll.Enabled = false;
}
else
{
buttonReplace.Enabled = true;
buttonReplaceAll.Enabled = true;
}
}
{
buttonFindNext.Enabled = false;
buttonReplace.Enabled = false;
buttonReplaceAll.Enabled = false;
}
else
{
buttonFindNext.Enabled = true;
if (string.IsNullOrEmpty(textBoxReplace.Text))
{
buttonReplace.Enabled = false;
buttonReplaceAll.Enabled = false;
}
else
{
buttonReplace.Enabled = true;
buttonReplaceAll.Enabled = true;
}
}