开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜