开发者

The State of a listView item in the DrawItem event is wrong

开发者 https://www.devze.com 2022-12-21 20:41 出处:网络
The question开发者_JAVA百科 is in the code. Cannot understand why this is happening. private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)

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

精彩评论

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