Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to disable serializing a property on a derived control?
 

How to disable serializing a property on a derived control?

I am trying to create a control derived from DataGridView. I'd like to basically make the columns static and not modifiable.
DataGridView has a property called Columns. VS designer serializes this property into .designer.cs file but I'd like to prevent the designer from doing that.
If the property was in my class then I could just slap on DesignerSerializationVisibility.Hidden on it but it's part of the base class. Is there a way to override this behavior?
doughboy  Tuesday, August 18, 2009 6:32 PM
If the Columns property is overridable, then override it and apply DesignerSerializationVisibility. If it is not overridable, then hide it using the new keyword and apply DesignerSerializationVisibilty. It will work. I did this for a derived ListView. The ListView serilaizes Items, but it is not overridable. However, hiding the Items property and providing my own did the trick just fine.
MCP
  • Proposed As Answer bywebJose Wednesday, September 23, 2009 4:56 AM
  •  
webJose  Friday, September 04, 2009 3:25 PM

You can use google to search for other answers

Custom Search

More Threads

• Simplest inherited control
• listBox or listView: 1 item=Multiple rows with formatting
• Cargar un formulario desde un parametro
• WinForms designer throws Exception when adding fillToolStrip component from DataSet without TableAdapters
• TextBox selection issue
• Error Message When Trying to Create a Data Source for a Compact Data Base in VS 2008
• Visual Studio abnormal shutdown when drop control on form
• Need help permanently maintaining the rectangle after a button click
• How to have text size adjust to fill space.
• CollectionEditor for Generic Objects doesn't show the type name correctly in Add Drop down.