tags:

views:

124

answers:

1

The question 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?

+2  A: 

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.

Jared
Thank you. Actually after some debugging and playing with the ListView properties I found this by myself. Just wasn't sure is it a bug or a feature. Now it's clear.
Zenya