Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User control properties

Status
Not open for further replies.

tzzdvd

Programmer
Aug 17, 2001
52
IT
Hi to all,
I am writing my first control.

My problem is with the property Size of the base UserControl class: I don't want the user to change the size of the control.

I have added in my class the following code:
Code:
private new Size Size
{
    set
    {
        base.Size = value;
    }
}

In this way I thought that who uses my control cannot use the property Size because it is hidden by mine. Only in the internal usage of the class I can modify this value.

Result: this code...
Code:
MyClass m = new MyClass();
m.Size = new Size(2, 3);
is correctly compiled without any warning.

Also, if I drag&drop my control in the GUI project of a form I can see this property in the property panel of the control.

Where is my mistake?
How can I hide a derived property?

I think this can be done because if I look at the class System.Windows.Forms.Timers there isn't any Size property but in the class System.Windows.Forms.Labels this property is present. Both classes derive from System.Windows.Forms so that both might have the Size property.

Thank's
Davide

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top