extends ISupportInitialize : Binder « GUI Windows Forms « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

   public class Form1 
   {
      static void Main()
      {
         BindingSource bindSource = new BindingSource();
         MyClass dataContainer = new MyClass();
         ISupportInitialize bindSourceInit = bindSource;
         ISupportInitialize dataInit = dataContainer;

         bindSourceInit.BeginInit();
         dataInit.BeginInit();

         dataContainer.StringCollection = new List<string>();
         bindSource.DataSource = dataContainer;
         bindSource.DataMember = "StringCollection";

         bindSourceInit.EndInit();
         dataInit.EndInit();
      }
      
   }

   public class MyClass : ISupportInitialize
   {
      private List<string> m_Data = null;
      private bool m_Initializing = false;
      private List<string> m_TempData = null;

      public List<string> StringCollection
      {
         get
         {
            return m_Data;
         }
         set
         {
            if (m_Initializing)
               m_TempData = value;
            else
               m_Data = value;
         }
      }

      void ISupportInitialize.BeginInit()
      {
         m_Initializing = true;
      }

      void ISupportInitialize.EndInit()
      {
         m_Data = m_TempData;
         m_Initializing = false;
      }

   }








23.86.Binder
23.86.1.extends Binder to create your own binder
23.86.2.extends ISupportInitialize