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