954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

MouesClick event not fired for Disabled or ReadOnly fields?

Hello,

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.

SoftwareGuy
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Why would someone click on a textbox that is disabled anyway? The whole idea of disabling the control is to show the user they can't interact with it.

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 166
 

They want a string that represents a "Help Description" for it to be displayed near the botton of the screen. Even if the field is disabled, the user will want to know what it's for, even though he or she can't change the selection.

SoftwareGuy
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Well if you disable the control, of course it isn't going to have events as it's disabled.

MouseClick does fire for ReadOnly, so not sure what your problem is there.

Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

Got it. So if it's ReadOnly=true, it works fine. This means I should be using [ReadOnly=false; Enabled=true] for Textboxes. Thanks for the heads up.

But now I'm having this problem with ComboBoxes and RadioButtons, since they don't have the ReadOnly field... What advice could you give me to simulate the effect of ReadOnly for these controls, while leaving Enabled set to true?

SoftwareGuy
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Tooltips aren't of any use to you? They display your help text when the control is hovered over

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 166
 

I know this was considered before, but they later rejected them for the sake of "consistency" with the behavior of the other parts of the application.

If this is the only way, I guess we can live without a help text, especially that it's self-explanatory in most cases...

I appreciate your time. You guys informed me that it's impossible with the control disabled. Thanks a lot.

SoftwareGuy
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Glad to help. I was also wondering how the help text was supposed to work if the button wasn't disabled. Then, clicking on it to get the help text would, of course, cause it to call whatever code it handles. Not very good from a usability point of view

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 166
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: