Hi,

I've created 'Windows Control Library' project in VS2005, created one control in this project which inherits from UserControl class like this:

class MyControl : UserControl
{
MyControl(){_myproperty = 0;}
int _myproperty;

int MyProperty
{
       get { return _myproperty;}
       set { _myproperty = value}
}
}

So, now, the property is not available in the 'Properties' window while in the designer.
While I compile and run, the 'Test container' appears, where I can see how MyControl works. In the 'Test container' MyProperty is available in the 'Properties'. This is something I can understand.

The problem is, when I add compiled control library reference to another project and add an instance of MyControl to some form in this new project. There is NO MyProperty in the 'Properties' for MyControl instance.

Ideas?

Dani AI

Generated

Short summary tied to the thread: reports that the property appears in the Test Container but not when the compiled control is dropped onto a form in another project. rightly suggested visibility, and 's request for the real code is sensible — this is usually either a visibility/attribute issue or a reference/version problem rather than a designer bug.

Checklist of accurate, actionable checks (one-sentence explanations):

  • Ensure the control class itself is declared public. If the type is internal, the designer will not expose its public members.
  • Ensure the property has public accessors (a public get at minimum); indexer or static members are not shown in the property grid.
  • Verify no hiding attributes are applied, e.g. [Browsable(false)] or an editor attribute that suppresses design-time visibility.
  • Confirm the referenced assembly is the expected build: clean/rebuild both projects, remove and re-add the reference, and verify the Reference Path/version in Solution Explorer (an older DLL or a GAC copy is a common culprit).
  • If the property type is a custom type, make sure a suitable TypeConverter or UITypeEditor is available; primitive types like int should show without extra work.
  • If Toolbox caching is suspected, remove the control from the toolbox and re-add it (or restart Visual Studio).

A small example of forcing design-time visibility (add these attributes in the control assembly if needed):

[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int MyProperty { get; set; }

See the Microsoft docs on BrowsableAttribute and DesignerSerializationVisibilityAttribute for exact behavior and edge cases.

Recommended Answers

All 3 Replies

u have to make it public in order to access it.
public int myProperty......

oh... sorry, it is public, I haven't copy-pasted the code - just typed it by hand. It is public and still all above occurs.

Thanks for reply, though

Could you post the real code, because otherwise we're just speculating. It really does look like the property isn't public. If the class is public, and the property is public, then you've got a tricky one on your hands. Let's see the code!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.