Supressing input in Inherited control

  • Thread starter Thread starter chris in grimsby
  • Start date Start date
C

chris in grimsby

I am developing a control that inherits the
system.windows.forms.checkbox

I want to supress user interaction such as the Click event and the
Keypress event when my control's custom property "ReadOnly" is true.

I expected to be able to override the OnClick and OnKeypress methods,
only calling the base object methods when ReadOnly is not true:

<code clip>
Public [ReadOnly] as boolean

Overrides Sub OnClick( e as EventArgs)
If not [ReadOnly] then
Mybase.OnClick(e)
End if
End Sub

<end clip>
but this just doesn't work.

Before anyone suggests it, the "Enabled" property is not good as it
greys out the caption (oops, sorry, text) shown on screen.

Any ideas?
 
* (e-mail address removed) (chris in grimsby) scripsit:
I am developing a control that inherits the
system.windows.forms.checkbox

I want to supress user interaction such as the Click event and the
Keypress event when my control's custom property "ReadOnly" is true.

Why not set the checkbox's 'AutoCheck' property to 'False'?
 
Why not set the checkbox's 'AutoCheck' property to 'False'?


Thanks for that.

Now how about a combobox?

In VB6 the combobox control had a "Locked" property to allow the
control to get focus but not allow the value to be changed by the
user. How can I do this in .net?

If it helps, I am only dealing with dropdownlist type comboboxes, so
the user cannot type directly into the textbox section, only select
from the list. I dont want to disable the control as this means it
cant get focus.
 
Back
Top