Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a Component which provides some Properties to other Controls.
For this the Component implements the IExtendedProvider and uses ProvideProperty to do this.
When I look inside the PropertyGrid of one of these Controls it doesn't look like I want to have it.
So my question is :
How can I define a Categorie for a provided Property ?
and the other question :
Inside the PropertyGrid the provided Property appears like :
"PropertyName" auf "ComponentName"
Could I change that in a way that the Property appears like every other Property of the Control (including a Description) ?

What I have tried:

the Component which provides the Properties is working well ...
Posted
Updated 1-Jan-21 13:38pm
v2

I had a similar issue some time ago, creating a scrolling marquee to display a message. I used the following to add properties to my control (C# but the idea is the same):
C#
public class Marquee : System.Windows.Forms.Control
{
    #region Additional properties specific to this control: modify them in the VS properties window
    private Color sColour = Color.Azure;
    [Category("Appearance"), Description("The starting gradient color of the text.")]
    public Color StartColor
    {
        get { return sColour; }
        set 
        {
            sColour = value; 
            Invalidate();
        }
    }

    private Color eColour = Color.Gold;
    [Category("Appearance"), Description("The ending gradient color of the text.")]
    public Color EndColor
    {
        get { return eColour; }
        set 
        {
            eColour = value; 
            Invalidate();
        }
    }

    private int timerInterval = 150;
    [Category("Appearance"), Description("Controls the marquee scrolling speed.")]
    public int ScrollDelay
    {
        get { return timerInterval; }
        set
        {
            timerInterval = value;
        }
    }
    #endregion properties

// remaining class code not relevant to the question

I could then use the Proprties window to modify the values in other applications.
 
Share this answer
 
Comments
Ralf Meier 29-Dec-20 8:13am    
Sorry Richard ... but I can't see how this Solution matches to my question.
Your example shows "regular" Properties from your customized Control. I have a Component which provides Properties to other Controls which normally don't belong to them ... here the Component really works with the Data of the provided Properties.
Richard MacCutchan 29-Dec-20 8:27am    
Changing the Category value adds it to the properties in my sample. But perhaps I have not understood what you are asking.
Ralf Meier 29-Dec-20 8:50am    
Okay ... sorry ...
I have a Component which uses ProvideProperty and Implements the IExtendedProvider. Those Properties, which come originally from the Component and are "provided" to the other Controls, I want to change the Category and the Description. With "normal" Properties, which directly belong to the Control, it is quiet clear for me.
Do I have explain it better now ?
Richard MacCutchan 29-Dec-20 8:57am    
Sorry, I still do not understand. If I change the Category in any of the above, then it creates a new Category in the Property grid. But I have done it directly in my control, rather than using ProvideProperty, so perhaps that is a different issue.
Ralf Meier 29-Dec-20 8:59am    
No problem ... and to ProvideProperty I can't give a Description and a Categorie directly - but perhaps there is a way I haven't found with Goggle yet ...
The mistake was the wrong keyword and the wromg place for searching.
Finally I found the answer by myself in this Forum instead of at Google by using the keyword "IExtendedProvider" instead of "ProvideProperty". Now I am leaded to this article https://www.codeproject.com/Articles/4683/Getting-to-know-IExtenderProvider where my questions are answered.
The DisplayName, the Category and the Description could be set at the Getter-Method for the provided Property.
 
Share this answer
 
v2

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