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;
}
}
|