前几天我问了一个question可能有点不清楚。现在我已经编写了可以更好地说明问题的代码。请看下面的代码第一:缩短这个,如果条件
int d;
d = DateTime.Today.Day;
if (d==1)
{
hyperlinkButton1.Background=new SolidColorBrush(Colors.Black);
}
else if (d==2)
{
hyperlinkButton2.Background=new SolidColorBrush(Colors.Black);
}
else if (d==3)
{
hyperlinkButton3.Background=new SolidColorBrush(Colors.Black);
}
else if (d==4)
{
hyperlinkButton4.Background=new SolidColorBrush(Colors.Black);
}
else if (d==5)
{
hyperlinkButton5.Background=new SolidColorBrush(Colors.Black);
}
else if (d==6)
{
hyperlinkButton6.Background=new SolidColorBrush(Colors.Black);
}
else if (d==7)
{
hyperlinkButton7.Background=new SolidColorBrush(Colors.Black);
}
else if (d==8)
{
hyperlinkButton8.Background=new SolidColorBrush(Colors.Black);
}
else if (d==9)
{
hyperlinkButton9.Background=new SolidColorBrush(Colors.Black);
}
else if (d==10)
{
hyperlinkButton10.Background=new SolidColorBrush(Colors.Black);
}
else if (d==11)
{
hyperlinkButton11.Background=new SolidColorBrush(Colors.Black);
}
else if (d==12)
{
hyperlinkButton12.Background=new SolidColorBrush(Colors.Black);
}
else if (d==13)
{
hyperlinkButton13.Background=new SolidColorBrush(Colors.Black);
}
else if (d==14)
{
hyperlinkButton14.Background=new SolidColorBrush(Colors.Black);
}
else if (d==15)
{
hyperlinkButton15.Background=new SolidColorBrush(Colors.Black);
}
else if (d==16)
{
hyperlinkButton16.Background=new SolidColorBrush(Colors.Black);
}
else if (d==17)
{
hyperlinkButton17.Background=new SolidColorBrush(Colors.Black);
}
else if (d==18)
{
hyperlinkButton18.Background = new SolidColorBrush(Colors.Black);
}
else if (d==19)
{
hyperlinkButton19.Background=new SolidColorBrush(Colors.Black);
}
else if (d==20)
{
hyperlinkButton20.Background=new SolidColorBrush(Colors.Black);
}
else if (d==21)
{
hyperlinkButton21.Background=new SolidColorBrush(Colors.Black);
}
else if (d==22)
{
hyperlinkButton22.Background=new SolidColorBrush(Colors.Black);
}
else if (d==23)
{
hyperlinkButton23.Background=new SolidColorBrush(Colors.Black);
}
else if (d==24)
{
hyperlinkButton24.Background=new SolidColorBrush(Colors.Black);
}
else if (d==25)
{
hyperlinkButton25.Background=new SolidColorBrush(Colors.Black);
}
else if (d==26)
{
hyperlinkButton26.Background=new SolidColorBrush(Colors.Black);
}
else if (d==27)
{
hyperlinkButton2.Background=new SolidColorBrush(Colors.Black);
}
else if (d==28)
{
hyperlinkButton28.Background=new SolidColorBrush(Colors.Black);
}
else if (d==29)
{
hyperlinkButton29.Background=new SolidColorBrush(Colors.Black);
}
else if (d==30)
{
hyperlinkButton30.Background=new SolidColorBrush(Colors.Black);
}
else
{
hyperlinkButton31.Background=new SolidColorBrush(Colors.Black);
}
我的问题(作为一个初学者)是这样的:有没有在C#中的任何方式通过使应用程序确定它依赖于改变其hyperlinkbutton背景缩短这个条件d
的值?
感谢您的帮助,这真的让我的生活更轻松;) – DreamNet 2012-02-04 08:32:46