Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove unnecessary properties from user control?

i want to remove unnecessary properties from user control. But I do not know what way?

like image 936
Sadegh Avatar asked Dec 08 '25 10:12

Sadegh


2 Answers

You can remove inherited properties from the Properties window with the [Browsable] attribute:

[Browsable(false)]
public override bool AutoScroll {
  get { return base.AutoScroll; }
  set { base.AutoScroll = value; }
}
[Browsable(false)]
public new Size AutoScrollMargin {
  get { return base.AutoScrollMargin; }
  set { base.AutoScrollMargin = value; }
}

Note the difference between the two, you have to use the "new" keyword if the property isn't virtual. You can use the [EditorBrowsable(false)] attribute to also hide the property from IntelliSense.

like image 122
Hans Passant Avatar answered Dec 12 '25 02:12

Hans Passant


You can't remove the properties your control inherits from UserControl.

You can, of course, remove properties you've created yourself. Just delete them from your source file.

like image 37
dtb Avatar answered Dec 12 '25 01:12

dtb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!