Locked property

  • Thread starter Thread starter Andrea Moro
  • Start date Start date
A

Andrea Moro

I'm writing my first windows control library. A simple
textbox with some numeric facilities.
Well, there is a strange thing that happen.

I want to add a locked property. As many other
property, because it's a default property, I must shadow
it, but unfortunately, despite the other properties shadowed,
for instance tabindex, locked continue to stay in design category
also if I set it up to behaviour, and doesn't run my own
code.

Anyone knows what's the problem?
 
Andrea,
TextBox doesn't have a Locked property, so why are you shadowing it?

The Locked property you see in the Properties Window is a Designer property!
Which means the Form designer itself is putting it there as it has special
meaning, similar to the Name & Modifier properties.

You may want to ask "down the hall" in the
microsoft.public.dotnet.framework.windowsforms.designtime newsgroup, to see
if there is a special attribute you can use to replace one of the Designer
properties.

Hope this helps
Jay
 
Well, I was referering to locked property of usercontrol.
By the way, I'll send a post to ng porposed by you and
wait for their answer.

In this way, there a lot of properties that I'd like to hide.

Andrea
 
Andrea,
UserControl doesn't have a Locked property either! ;-)

In fact there are no Windows Form controls that have a locked property.

The Locked property you see in the Properties Window is a Designer property!
Which means the Form designer itself is putting it there as it has special
meaning, similar to the Name & Modifier properties.

Hope this helps
Jay
 
Jay

this may usefull, but why then I can't add my locked
property. If it has - as it is - only a design means, why
framework wouldn't know to let me add it?

Is there a list of these "designer properties" on which
us haven't any power?

Andrea
 
Andrea,
this may usefull, but why then I can't add my locked
property. If it has - as it is - only a design means, why
framework wouldn't know to let me add it?
You are completely free to add a Locked property to your control, You are
completely free to get & set that property in code. This property DOES NOT
need to be shadowed (as the base class does not have a Locked property!)

Public Class LockableControl
Inherits System.Windows.Forms.UserControl

Private m_locked As Boolean

"Windows Form Designer generated code"

<Browsable(True), _
Category("Appearance"), _
Description("This is my property!")> _
Public Property Locked() As Boolean
Get
Return m_locked
End Get
Set(ByVal value As Boolean)
m_locked = value
End Set
End Property

End Class

You just cannot display the property in the Forms designer, as the forms
designer shows its own Locked property.

As I stated, You may want to ask "down the hall" in the
microsoft.public.dotnet.framework.windowsforms.designtime newsgroup, to see
if there is a special attribute you can use to replace one of the Designer
properties. I will do some more checking and get back to you.

By "special attribute" I mean a class that inherits from System.Attribute,
such as Browsable, Category & Description in my example above.

If you were able to add you own Locked or Modifiers properties, which makes
some sense to me you should. How would the designer expose its own Locked &
Modifiers properties?
Is there a list of these "designer properties" on which
us haven't any power?
Open a form in design mode, look under the "Design" category, there are
three listed (Name), Locked, and Modifiers.

Hope this helps
Jay
 
Andrea,
To add a Locked property to your control and have it show up in the
designer:

"You need to create your own designer in this instance and block the base
implementation of PreFilterProperties. ControlDesigner.PreFilterProperties
is responsible for putting "Locked" on the control."

I don't have a clean example of creating your own designer, but you will
need to inherit from ControlDesigner or one of its subclasses. Post if you
need help.

The other option I was going to suggest, which is easier, is the one
Jonathan just suggested, give your Locked property a different name, as the
ControlDesigner itself is adding the property to the grid causing your
Locked property to be hidden.

Hope this helps
Jay
 

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

Back
Top