private void ParentManager_CurrentItemChanged(object sender, EventArgs e)
 {
     if (!IgnoreItemChangedTable.Contains(this.parentManager))
     {
         int listposition = base.listposition;
         try
         {
             base.PullData();
         }
         catch (Exception exception)
         {
             base.OnDataError(exception);
         }
         if (this.parentManager is CurrencyManager)
         {
             CurrencyManager parentManager = (CurrencyManager)this.parentManager;
             if (parentManager.Count > 0)
             {
                 this.SetDataSource(this.fieldInfo.GetValue(parentManager.Current));
                 base.listposition = (this.Count > 0) ? 0 : -1;
             }
             else
             {
                 parentManager.AddNew();
                 try
                 {
                     IgnoreItemChangedTable.Add(parentManager);
                     parentManager.CancelCurrentEdit();
                 }
                 finally
                 {
                     if (IgnoreItemChangedTable.Contains(parentManager))
                     {
                         IgnoreItemChangedTable.Remove(parentManager);
                     }
                 }
             }
         }
         else
         {
             this.SetDataSource(this.fieldInfo.GetValue(this.parentManager.Current));
             base.listposition = (this.Count > 0) ? 0 : -1;
         }
         if (listposition != base.listposition)
         {
             this.OnPositionChanged(EventArgs.Empty);
         }
         this.OnCurrentChanged(EventArgs.Empty);
         this.OnCurrentItemChanged(EventArgs.Empty);
     }
 }
        private void ParentManager_CurrentChanged(object sender, EventArgs e)
        {
            int oldlistposition = this.listposition;

            // we only pull the data from the controls into the backEnd. we do not care about keeping the lastGoodKnownRow
            // when we are about to change the entire list in this currencymanager.
            try {
                PullData();
            } catch {}

            if (parentManager is CurrencyManager)
            {
                CurrencyManager curManager = (CurrencyManager)parentManager;
                if (curManager.Count > 0)
                {
                    SetDataSource(fieldInfo.GetValue(curManager.Current));
                    listposition = (Count > 0 ? 0 : -1);
                }
                else
                {
                    // really, really hocky.
                    // will throw if the list in the curManager is not IBindingList
                    // and this will fail if the IBindingList does not have list change notification. read on....
                    // when a new item will get added to an empty parent table,
                    // the table will fire OnCurrentChanged and this method will get executed again
                    curManager.AddNew();
                    curManager.CancelCurrentEdit();
                }
            }
            else
            {
                SetDataSource(fieldInfo.GetValue(parentManager.Current));
                listposition = (Count > 0 ? 0 : -1);
            }
            if (oldlistposition != listposition)
            {
                OnPositionChanged(EventArgs.Empty);
            }
            OnCurrentChanged(EventArgs.Empty);
        }
示例#3
0
        private void ParentManager_CurrentItemChanged(object sender, EventArgs e)
        {
            if (IgnoreItemChangedTable.Contains(parentManager))
            {
                return;
            }

            int oldlistposition = this.listposition;

            // we only pull the data from the controls into the backEnd. we do not care about keeping the lastGoodKnownRow
            // when we are about to change the entire list in this currencymanager.
            try {
                PullData();
            }
            catch (Exception ex) {
                OnDataError(ex);
            }

            if (parentManager is CurrencyManager)
            {
                CurrencyManager curManager = (CurrencyManager)parentManager;
                if (curManager.Count > 0)
                {
                    // Parent list has a current row, so get the related list from the relevant property on that row.
                    SetDataSource(fieldInfo.GetValue(curManager.Current));
                    listposition = (Count > 0 ? 0 : -1);
                }
                else
                {
                    // APPCOMPAT: bring back the Everett behavior where the currency manager adds an item and
                    // then it cancels the addition.
                    //
                    // really, really hocky.
                    // will throw if the list in the curManager is not IBindingList
                    // and this will fail if the IBindingList does not have list change notification. read on....
                    // when a new item will get added to an empty parent table,
                    // the table will fire OnCurrentChanged and this method will get executed again
                    // allowing us to set the data source to an object with the right properties (so we can show
                    // metadata at design time).
                    // we then call CancelCurrentEdit to remove the dummy row, but making sure to ignore any
                    // OnCurrentItemChanged that results from this action (to avoid infinite recursion)
                    curManager.AddNew();
                    try {
                        IgnoreItemChangedTable.Add(curManager);
                        curManager.CancelCurrentEdit();
                    } finally {
                        if (IgnoreItemChangedTable.Contains(curManager))
                        {
                            IgnoreItemChangedTable.Remove(curManager);
                        }
                    }
                }
            }
            else
            {
                // Case where the parent is not a list, but a single object
                SetDataSource(fieldInfo.GetValue(parentManager.Current));
                listposition = (Count > 0 ? 0 : -1);
            }
            if (oldlistposition != listposition)
            {
                OnPositionChanged(EventArgs.Empty);
            }
            OnCurrentChanged(EventArgs.Empty);
            OnCurrentItemChanged(EventArgs.Empty);
        }
示例#4
0
 /// <summary>
 /// Init data
 /// </summary>
 /// <remarks>
 /// Author:			PhatLT. FPTSS.
 /// Created date:	14/02/2011
 /// </remarks>
 private void InitData()
 {
     dt = bo.GetSchemaTable();
     _manager = (CurrencyManager)this.BindingContext[dt];
     _manager.AddNew();
     _manager.Position = 0;
     BindDataToControl();
     bln_IsEdit = false;
     ep.DataSource = dt;
 }
示例#5
0
 protected override void SetColumnValueAtRow(CurrencyManager source, int rowNum, object value)
 {
     //Rectangle rect= this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
     if (rowNum!=this.DataGridTableStyle.DataGrid.CurrentCell.RowNumber)
     {
         //source.Position=this.DataGridTableStyle.DataGrid.CurrentCell.RowNumber;
         //if (this.DataGridTableStyle.DataGrid.CurrentCell.RowNumber>this.getDataTable.Rows.Count-1)
         source.AddNew();
     }
     base.SetColumnValueAtRow (source, rowNum, value);
     //pSparrow.pItemText = pSparrow.pTreeView.SearchByText(value.ToString()).Text;
 }