views:

92

answers:

1

For a WinForms control, I'd like to move certain settings into a sub object. One of them is a custom class containing all UI Strings, the other a OpenFileDialog:

class MyControl: Control
{
  // ...
  private OpenFileDialog m_dlgOpen = new OpenFileDialog();
  public OpenFileDialog DialogOpen
  {
     get { return m_dlgOpen; }
  }
}

This adds the sub object to the designer, and allows to edit its properties (e.g. title, default extension, filter). However, the changes are nto added to the InitalizeComponent method, so they are lost.

Is it possible to make this properties "persist" in the InitializeComponent method?

+2  A: 

Tell the designer to serialize the object itself:

  [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  public OpenFileDialog DialogOpen {
    get { return m_dlgOpen; }
  }
Hans Passant