Click here to Skip to main content
16,020,666 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have a form with a Color property .How can I show it in properties window in designer mode .
Posted

If you need to show a property of your own in the design window, you have to base a from on a derived form.
I.e.
public class MyFormWithProperty : Form
   {
   public int MyProperty { get; set; }
   public MyFormWithPropertyfrmTesting()
       {
       InitializeComponent();
       }
   }
And then derive your form instance from that:
public class MyFormInstance : MyFormWithProperty
   {
   public MyFormInstance()
       {
       InitializeComponent();
       }
   }
When you look at the properties for MyFormInstance, it will have the MyProperty property.

It sounds confusing: but just try it - you will see what I mean!
 
Share this answer
 
Comments
mojtaba pirveisi 12-Jun-11 7:25am    
thanks , but is there any neat way? like browseable attribute
OriginalGriff 13-Jun-11 3:15am    
The design window can only show the properties of the base class for an object: it can't show the properties you add via code: to see them, you must derive an object from the class.
The Browseable attribute defaults to "true" and is provided to prevent properties becoming visible in the Designer!
Sergey Alexandrovich Kryukov 12-Jun-11 15:22pm    
Correct, a 5. OP did not understand it, so I put another answer, please see.
--SA
If this is a public property of your form class, the PropertyGrid shows it automatically.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900