ListBox,OwnerDrawVariable...MeasureItem is called only once?

  • Thread starter Thread starter Özden Irmak
  • Start date Start date
Ö

Özden Irmak

Hello,

I've derived from ListBox control to create a special control. This
control's DrawItem property is OwnerDrawVariable. When the items are get
drawn, OnMeasureItem is called once but only once. No matter you resize the
control, etc. will not cause this event to be re-called again.

I have to recalculate the Item heights when the width of the control is
changed but this seems not to be possible? Is this a bug? Anyworkaround?

Thanks in advance,

Özden
 
I found a solution...On the Resize event, I call RefreshItem for everyitem
in the listbox and this raises OnMeasureItem event...

Regards,

Özden
 
how are you handling selection in you control. i am running into some
selection issues on my ownerdrawn control.
 
This is what I use on OnDrawItem :

//Draw Border if selected

if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)

{

e.Graphics.DrawRectangle(MyPen,e.Bounds.Left+12,e.Bounds.Top+2,e.Bounds.Width
- 14,e.Bounds.Height - 4);

}

What kind of selection problem do you have?

Regards,

Özden
 
Back
Top