XPTable.Models.Table.TryDataBinding C# (CSharp) Method

TryDataBinding() private method

Gets the CurrencyManager by the BindingContext, unwires the old CurrencyManager (if needed), and wires the new CurrencyManager. Then it calls calculateColumns and updateAllData.
private TryDataBinding ( ) : void
return void
        private void TryDataBinding()
        {
            if (this.DataSource == null || base.BindingContext == null)
                return;

            CurrencyManager cm;
            try
            {
                cm = (CurrencyManager)base.BindingContext[this.DataSource, this.DataMember];
            }
            catch (System.ArgumentException)
            {
                // If no CurrencyManager was found
                return;
            }

            if (this.dataManager != cm)
            {
                // Unwire the old CurrencyManager
                if (this.dataManager != null)
                {
                    //                    this.dataManager.ListChanged -= listChangedHandler;	// only in .Net 2.0
                    this.dataManager.PositionChanged -= positionChangedHandler;
                    if (this.dataManager.List is IBindingList)
                        ((IBindingList)this.dataManager.List).ListChanged -= listChangedHandler;	// OK for .Net 1.1
                }
                this.dataManager = cm;

                // Wire the new CurrencyManager
                if (this.dataManager != null)
                {
                    //                    this.dataManager.ListChanged += listChangedHandler;	// only in .Net 2.0
                    if (this.dataManager.List is IBindingList)
                        ((IBindingList)this.dataManager.List).ListChanged += listChangedHandler;	// OK for .Net 1.1
                    this.dataManager.PositionChanged += positionChangedHandler;
                }

                // Update metadata and data
                CalculateColumns();

                UpdateAllData();
            }
        }
Table