views:

44

answers:

4

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 library?.

A very big thanks in advance.

A: 

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.

Kangkan
HTML / CSS .. i am using visual studio c sharp form
apals
In that case, just expose those properties that you need outside and implement setting the values to the controls in your code. Do not expose the objects directly.
Kangkan
@Kangkan settings are the same properties from the same assembly, just from other class. So they have to have their access modifier set to public too to be accessible from another project. (or maybe i didn't quite understand your answer? sorry then)
nihi_l_ist
I am saying the same what you are telling. You need public properties and in the setter, set the backgrounds accordingly. See the code sample provided by @eschneider. Have you done something similar?
Kangkan
A: 

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).

nihi_l_ist
+2  A: 

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;
        }
    }
eschneider
A: 

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.

B.Mo