Search code examples
.neteventsreadonlymouseclick-event

MouseClick event not fired for disabled or read-only fields?


I'm using .NET C# there. I have a textbox. I assigned it a MouseClick event.

Normally the event is fired when I click the control.

But if I set the textbox's [Enabled=false] or [ReadOnly=true] properties, the MouseClick event is not fired.

How can I fix it?

Thanks.


Solution

  • clearly disabling the control is the issue, you could leave it enabled and not read-only then in the KeyPress/KeyDown event you avoid/cancel any input so the user cannot change the content.