Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How can I hide a property? (DockPadding)
 

How can I hide a property? (DockPadding)

I have created a control based on the (System.Windows.Forms.ContainerControl), everything until now was fine, I am adding the final touches to the control, and one of those touches is preventing Visual Studio.NET from automatically generating these two lines of code for my control.

this.ltOutlookPanel1.DockPadding.Left = 1;
this.ltOutlookPanel1.DockPadding.Right = 2;

I did try to override the (DockPadding) property, but this did not work, I try to create a new private property with the same name, and VS.NET was still able to access the property.

Who can I hide this property completely, or at least hide if from the code generator, I tried the (ShouldSerializeDockPadding) and it does not work either

It is not a big problem for me if the code is generated for that property, I just need the idea of how can I hide a property like that.
MigrationUser 1  Monday, April 14, 2003 10:29 AM
By the way, I just tried adding this piece of code to the control (my control), while there was another form opened containing the control, after compile I’ve switched to the form that has the control (my control) and Visual Studio.NET 2003 crashed.

[DesignerSerializationVisibility(DesignerSerializationVisibility.Default)]
public System.Windows.Forms.ScrollableControl.DockPaddingEdges DockPadding
{
   get
   {
      return this.DockPadding;
   }
}
MigrationUser 1  Monday, April 14, 2003 11:33 AM
I found the right way of removing the property, in the control designer the following code worked perfectly:

internal class LTGlobalDesigner : ParentControlDesigner
{

....

protected override void PostFilterProperties(IDictionary properties)
{
properties.Remove("DockPadding");
base.PostFilterProperties(properties);
}

....

}
MigrationUser 1  Wednesday, April 16, 2003 7:45 PM
That works fine.  Another way to do it should be this:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // don't serialize
[Browsable(false)] // don't show in the grid
[EditorBrowsable(EditorBrowsableState.Never] // don't show in intellisense
public new DockPaddingEdges DockPadding {
    get { return base.DockPadding; }
}
MigrationUser 1  Thursday, May 15, 2003 6:22 PM

You can use google to search for other answers

Custom Search

More Threads

• "ICO.ICO" - Icon Help
• WYSIWYG HTML Editor Control
• Inherits ListBox and Databinding
• Custom Toolstrip Collection Items options are not save.
• How I Make a form a Resolution Independent Form?
• How to capture an event of a control y ParentForm
• Collection Editor Problems
• WSOD Issue in Designer
• Ressources embedded problem with a compilation on the fly
• DataGridColumnStyle Button Control