public virtual void DataBind(System.Data.DataTable Data, string column)>The BBCheckBoxString is mainly for handling legacy database columns that had the bad design of using a char instead of a bit. <g>
>>>public class BBCheckBoxString : System.Windows.Forms.CheckBox >>>{ >>> protected Binding oBinding = null; >>> >>> public virtual void DataBind(System.Data.DataTable Data, string Column) >>> { >>> this.Checked = false; >>> this.oBinding = new Binding("Checked", Data, Column); >>> >>> this.oBinding.Format += new ConvertEventHandler(this.FormatHandler); >>> this.oBinding.Parse += new ConvertEventHandler(this.ParseHandler); >>> >>> this.DataBindings.Add(this.oBinding); >>> } >>> protected override void FormatHandler(object sender, ConvertEventArgs e) >>> { >>> if (e.Value.ToString() == "Y") >>> e.Value = true; >>> else >>> e.Value = false; >>> } >>> protected override void ParseHandler(object sender, ConvertEventArgs e) >>> { >>> if ((bool)e.Value == true) >>> e.Value = "Y"; >>> else >>> e.Value = "N"; >>> } >>>} >>>>>>
>>>this.MyCheckBox.DataBind(MyTable, "MyYNColumn"); >>>>>>
>>>public class BBCheckBox : System.Windows.Forms.CheckBox >>>{ >>> #region Declarations >>> protected Binding oBinding = null; >>> protected CurrencyManager oCurrency = null; >>> protected DataTable m_BoundTable = null; >>> protected string m_BoundColumn = ""; >>> protected bool m_ReadOnly = false; >>> #endregion >>> >>> #region Methods >>> public virtual void DataBind(System.Data.DataTable Data, string column) >>> { >>> this.Checked = false; >>> >>> this.m_BoundTable = Data; >>> this.m_BoundColumn = column; >>> this.oBinding = new Binding("Checked", Data, column); >>> >>> this.oBinding.Format += new ConvertEventHandler(this.FormatHandler); >>> this.oBinding.Parse += new ConvertEventHandler(this.ParseHandler); >>> >>> this.DataBindings.Add(this.oBinding); >>> >>> if (this.BindingContext != null) >>> { >>> this.oCurrency = (CurrencyManager)this.BindingContext[this.oBinding.DataSource]; >>> this.oCurrency.PositionChanged += new EventHandler(this.PositionChangedHandler); >>> } >>> >>> this.SetEOF(); >>> } >>> protected virtual void SetEOF() >>> { >>> if (this.oCurrency == null) >>> return; >>> >>> if (this.oCurrency.Position < 0) >>> this.Enabled = false; >>> else >>> this.Enabled = !this.ReadOnly; >>> } >>> #endregion >>> >>> #region Events >>> protected virtual void FormatHandler(object sender, ConvertEventArgs e) >>> { >>> if (e.Value == System.DBNull.Value) >>> e.Value = false; >>> } >>> protected virtual void ParseHandler(object sender, ConvertEventArgs e) >>> { >>> } >>> protected virtual void PositionChangedHandler(object sender, System.EventArgs e) >>> { >>> this.SetEOF(); >>> } >>> >>> #endregion >>> >>> #region Properties >>> [DefaultValue(false)] >>> public bool ReadOnly >>> { >>> get { return this.m_ReadOnly; } >>> set >>> { >>> this.m_ReadOnly = value; >>> this.Enabled = !value; >>> } >>> } >>> >>> #endregion >>>} >>>>>>
>>>>this.chkStatus.DataBindings.Add("Checked", bindingSource1, "Status=='A'"); >>>>>>>>