开发者

windows control library in c sharp

I have just added a textbox, button, label to validate ID of 12 characters. The library is called check_ID. It works fine. The only problem is i have to access the forecolor of label, backcolor of textbox , forecolor of button as per color scheme of the project.

But it seems that none of the properties of the objects in check_ID are available for modification.

I have even changed the modifier to public of all objects by repoening the check_ID project.

Is there another way to access the properties of these objects that are created using windows control librar开发者_JAVA技巧y?.

A very big thanks in advance.


You need to add the properties to the usercontrol or check_ID object. Then inside the property you can set/get the child control properties.

   public override Color ForeColor
    {
        get
        {
            return base.ForeColor;
        }
        set
        {
            base.ForeColor = value;

            //Set child controls here:
            textbox.ForeColor = value;
        }
    }


You need to explicitly expose the properties and set the properties in your code to set such things from outside. Alternatively, you can just put adequate CSS class for the HTML elements. This will enable any programmer using your control to set these properties from outside.


I think no. If you want to change some properties from another project they MUST be public(use "internal" if you want to give access to properties in the SAME assembly).


In the property sheet of the base control you should set the Modifiers property for each child control that you'll want to manipulate to Protected. You should then be able to alter them in any derived controls.

You could also provide wrapper methods / properties for any specific functionality. Manipulating controls via the visual designer / property sheet is a more intuitive experience, however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜