winUserControl in VS2010 - properties are not visible in designer
I believe this the normal behavior of VS2010 and assume it's by design. It behaves the same for me in 2010 Ultimate. When you place UserControl1
on a form, you'll see its custom properties.
My guess is this is because when you're designing the control, there is no instance of your control yet (it may not have even been compiled). What you're looking at is an instance of UserControl
. When you compile your control and then add it to a form, the designer creates an instance of your control, so its properties can be seen and manipulated.
mj82
Updated on June 15, 2022Comments
-
mj82 almost 2 years
I have a problem with (I suppose) my Visual Studio 2010 Express environment: when I design my own UserControl, in Properties grid I can't see public properties of that control. They are however visible in the project, that reference this control.
As it's Express Edition, I create new empty project, then add new UserControl to it.
Then, for a test, I put following code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace Project1 { public partial class UserControl1 : UserControl { private int myNumber; [Browsable(true)] public int MyNumber { get { return myNumber; } set { myNumber = value; } } public UserControl1() { InitializeComponent(); } } }
In VS 2008, as I remember, that should be enogh to show MyNumber property in Properties grid, even without
[Browsable(true)]
attribute. In VS 2010 however, when I double click UserControl1.cs in Solution Explorer and look in Properties, I don't see MyNumber.
When I reference and use this control in another project, there is an access to it's properties.I've tried to competly reinstall VS 2010 environment, including SP1, but with no success. Do you have any idea what can be wrong?
By the way: none of these attributes are working, either:
[Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Bindable(true)]
Best regards,
Marcin-
Shaun Wilson over 9 yearspossible duplicate of Event using generic EventHandler<> not visible in Designer
-
-
mj82 almost 13 yearsUnfortunately, it's not working, too. AFAIK, if I don't put any category, there should be one by default.
-
mj82 almost 13 yearsI think that's it - I must have mixed something, it's been a while since I last design UserControl... I've tried it on 2 other computers with VS 2010 (with old and fresh install), and at both there were the same behaviour. Thanks.
-
melodiouscode over 10 yearsOn top of Billy's answer. You also need to rebuild your project as I have just realised!
-
binki almost 10 yearsEven without a category, arbitrary properties should show up under “Misc”. But maybe this only applies to VS 2013+?