Start by thinking about what you want to do. This won't work:
if (txt_Hours.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = true;
txt_Seconds.Enabled = false;
}
if (txt_Minutes.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = false;
txt_Seconds.Enabled = true;
}
if (txt_Seconds.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = false;
txt_Seconds.Enabled = false;
}
Because if the first case passes, it sets a condition which makes the second case pass (by enabling txt_Minutes), which sets a condition which makes the third case pass - so regardless of which condition it start in, it always ends up teh same: All disabled.
You can do it, with
else
conditions:
if (txt_Hours.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = true;
txt_Seconds.Enabled = false;
}
else if (txt_Minutes.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = false;
txt_Seconds.Enabled = true;
}
else if (txt_Seconds.Enabled == true)
{
txt_Hours.Enabled = false;
txt_Minutes.Enabled = false;
txt_Seconds.Enabled = false;
}
else
{
}
But you can't do that easily with a
switch
because switch expressions only ever work with sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or enum values, and case statements only work with constant values.