我正在使用 ListView 来显示我的数据。在 ItemDatabound 事件中,我想做一些操作并更改一些显示的数据。当我检查此事件中的项目时,我使用以下代码,但我需要知道该项目是否是交替项目,因为这将影响我想要对该行执行的操作。谁能指出我正确的方向?
if (e.Item.ItemType == ListViewItemType.DataItem)
{
ListViewDataItem currentItem = (ListViewDataItem)e.Item;
DataKey currentDataKey = myLilstView.DataKeys[currentItem.DataItemIndex];
//Do something
}
最佳答案
看看这是否有效:
int currentIndex = currentItem.DisplayIndex;
if (currentIndex % 2 == 1)
{
// alternating item
}
关于c# - ListView ItemDataBound - 确定项目是否为 AlternatingItem?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1558410/