ComboBox

D

Dmitry Nogin

Hi,

I inherited from ComboBox:

class MyCombo : ComboBox
{
public event EventHandler Changed;
}

How to raise "Changed" event when one calls my Items.Remove(...) method?

myCombo.Items.Remove("Jim");

Is there anything to override?


thanks,
dmitry
 
J

Jared

You could make your own sub for removing items..

public sub remove_item(index as int)

'remove item
'fire func / raise event

end sub
 
D

Dmitry Nogin

My solution is:

protected override void WndProc(ref Message m)
{
const int CB_DELETESTRING = 0x0144;
if (m.Msg == CB_DELETESTRING)
if (m.WParam == (IntPtr)this.SelectedIndex)
{
base.WndProc(ref m);
if (Changed != null)
Changed(this, EventArgs.Empty);

return;
}

base.WndProc(ref m);
}
 

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