The State of a listView item in the DrawItem event is wrong
The question开发者_JAVA百科 is in the code. Cannot understand why this is happening.
private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
// This works Ok
if (e.Item.Selected)
{
// ...
}
// This works wrong!
// e.State is always Selected! Why?
if ((e.State & ListViewItemStates.Selected) != 0))
{
// ...
}
}
Does someone have a similar problem?
This looks like a known bug since about 2006, in evidence when the ListView.HideSelection
property is set to FALSE
.
The only workaround on file is to do what you've already done: use e.Item.Selected
.
Here is a link to the bug report - looks like it's been relegated to low priority so far.
精彩评论