我使用DataRepeater
控件来显示弹出窗口。我可以通过此代码
BackColor
private void dataRepeater1_CurrentItemIndexChanged(object sender, EventArgs e)
{
dataRepeater1.CurrentItem.BackColor = Color.Red;
}
但我无法为上一项添加BackColor
白色。此外,我想从我悬停鼠标的列表中更改项目的BackColor
。
答案 0 :(得分:0)
解决此问题的一种方法是在班级中再增加一个属性,可能称为DataRepeater1_PreviousItem
:
class YourClass
{
DataRepeaterItem DataRepeater1_PreviousItem { get; set; }
// ... some other code
private void dataRepeater1_CurrentItemIndexChanged(object sender, EventArgs e)
{
if (DataRepeater1_PreviousItem != null)
DataRepeater1_PreviousItem.BackColor = Color.White;
dataRepeater1.CurrentItem.BackColor = Color.Red;
DataRepeater1_PreviousItem = dataRepeater1.CurrentItem;
}
}