Question

I have an owner-drawn listbox control.

The problem is that sometimes the DrawItemEventArgs argument passed to my DrawItem event-handler has an Index property of "-1". This is my unethical fix:

private void lstBox_DrawItem(object sender, DrawItemEventArgs e)
{
    if (e.Index >= 0)
    {
        handler implementation
    }
}

I'd like to know what normally causes a negative index to be passed to the handler.

Was it helpful?

Solution

This may be when the listbox is empty, but receives the focus - e.g. if the list is cleared on closing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top