The DrawItemEventArgs "Index" property sometimes becomes negative

I have an owner-driven list 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 solution:

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

I would like to know what usually causes a negative index for the handler.

+4
source share
1 answer

This can be when the list is empty, but receives focus - for example, if the list is reset when it is closed.

+2
source

All Articles