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

Ö

Ö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
 
Ö

Özden Irmak

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

Regards,

Özden
 
J

Jeremy

how are you handling selection in you control. i am running into some
selection issues on my ownerdrawn control.
 
Ö

Özden Irmak

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top