The state of the listView element in the DrawItem event is incorrect

The question is in the code. I can’t 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 anyone have a similar problem?

+3
source share
1 answer

This seems like a known bug from 2006 when the property was set ListView.HideSelectionto FALSE.

The only workaround for the file is to accomplish what you have already done: use e.Item.Selected.

There is a link to the bug report here - it looks like it has been ranked low so far.

+3
source

Source: https://habr.com/ru/post/1735562/


All Articles