title: Binding Windows Forms to SqlConnectionStringBuilder
body: <p>Could someone show tell me why when I try to bind a text box to a  SqlConnectionStringBuilder instance it doesn't work and I receive the error.</p>
  
  <p>"Cannot bind to the property or column DataSource on the DataSource.\r\nParameter name: dataMember"</p>
  
  <p>It seems like binding manager can't find the property when it reflects to find it.</p>
  
  <p>If I write a 'do nothing' wrapper that just forwards get/set operations it works as expected.</p>
  
  <p>I've reflected SqlConnectionStringBuilder object and didn't see anything that would lead me to think that I couldn't bind to it directly to it's properties.</p>
  
  <p>Here's a mock up of the code I'm using...</p>
  
  <pre><code>public partial class frmMain : Form {
  
      private BindingSource bindingSource = new BindingSource();
  
      public frmMain() {
          InitializeComponent();
  
          //bindingSource.DataSource = typeof(SqlConnectionStringBuilderWrapper);
          bindingSource.DataSource = typeof(SqlConnectionStringBuilder);
  
          tbDataSource.DataBindings.Add("Text", bindingSource, "DataSource");
  
          initializeConnectionStrings();
      }
  
      private void initializeConnectionStrings() {
          SqlConnectionStringBuilder defaultBuilder = null;
          cmbConnectionStrings.DataSource = SqlConnectionStrings.ConnectionBuilders(out defaultBuilder);
  
          //bindingSource.DataSource = new SqlConnectionStringBuilderWrapper(defaultBuilder);
          bindingSource.DataSource = defaultBuilder;
  
          cmbConnectionStrings.SelectedItem = defaultBuilder;
      }
  }
  
  public class SqlConnectionStringBuilderWrapper : INotifyPropertyChanged {private SqlConnectionStringBuilder builder = null;
  
      public SqlConnectionStringBuilderWrapper(SqlConnectionStringBuilder builder) { this.builder = builder; }
      public SqlConnectionStringBuilder Builder { get { return builder; } set {} }
  
      public string DataSource {
          get { return builder.DataSource; }
          set {
              if (builder.DataSource != value) {
                  builder.DataSource = value;
                  OnPropertyChanged("DataSource");
              }
          }
      }
  ...
  }
  </code></pre>
  
  <p>If I change the DataSource assignments to the commented versions.  It works.  I just don't understand why the wrapper is needed.</p>
  
  <p>Thanks!</p>