使用C#的WinForms(3.5)。
是否有可能设置行的颜色,自动交替在ListView?
或者我需要一个新的行添加到列表视图每次手动设置行的颜色?
基于一个 MSDN 文章的手动的方法是这样的:
//交替行的颜色
如果(我%2 == 0)
{
lvi.BackColor = Color.LightBlue;
}
其他
{
lvi.BackColor = Color.Beige;
}
解决方案
我恐怕是的WinForms的唯一途径。 XAML允许这种通过使用样式虽然。
Using C# Winforms (3.5).
Is it possible to set the row colors to automatically alternate in a listview?
Or do I need to manually set the row color each time a new row is added to the listview?
Based on a MSDN article the manual method would look like this:
//alternate row color
if (i % 2 == 0)
{
lvi.BackColor = Color.LightBlue;
}
else
{
lvi.BackColor = Color.Beige;
}
解决方案
I'm afraid that is the only way in Winforms. XAML allows this through use of styles though.