What's wrong in my code?

  • Thread starter Thread starter jean-dot-paul-at-opelwilly-dot-com
  • Start date Start date
J

jean-dot-paul-at-opelwilly-dot-com

Hello,

I want to swalow all mousclicks in a comboBox control.
I created wy own 'public class roComboBox : System.Windows.Forms.ComboBox '
Created a property ReadOnly and call only the base events if the ReadOnly is
false (see code beneath) but the mousclicks still pass.

Is there such thing as in KeyPress like .Handeled = true ?

Who knows what Im doing wrong ?

Jean Paul

protected override void OnMouseDown(MouseEventArgs e)

{

if (!lokReadOnly)

{

base.OnMouseDown(e);

}

}

protected override void OnMouseUp(MouseEventArgs e)

{

if (!lokReadOnly)

{

base.OnMouseUp (e);

}

}

protected override void OnClick(EventArgs e)

{

if (!lokReadOnly)

{

base.OnClick (e);

}

}


public bool ReadOnly

{

get

{

return lokReadOnly;

}

set

{

lokReadOnly = value;

if (lokReadOnly)

{

this.BackColor = Color.Yellow;

}

else

{

this.BackColor = Color.White;

}

}

}
 
I suspect that when the code reaches OnMouseDown, the default behavior of a
mouse down has already occured. In other words, it's too late. You might
have to override WndProc and catch the WM_MOUSEDOWN message there.

Kennedy
 
I think Kennedy is right. I guess the ComboBox baseclass does not rely
on derived classes to call base.XXX() from overridden methods. I'd
suggest you override WndProc and handle it there.

Regards
Senthil
 
tnx Senthil and Kennedy, I begon to have those ideas to. I look for other
sollution.

Greets

Jean Paul
 
Back
Top