Provides data for the BeginEdit, StopEdit and CancelEdit events of a Table
Наследование: XPTable.Events.CellEventArgsBase
Пример #1
0
 /// <summary>
 /// Raises the EndEdit event
 /// </summary>
 /// <param name="e">A CellEditEventArgs that contains the event data</param>
 protected virtual void OnEndEdit(CellEditEventArgs e)
 {
     if (this.EndEdit != null)
     {
         this.EndEdit(this, e);
     }
 }
Пример #2
0
        /// <summary>
        /// Prepares the CellEditor to edit the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to be edited</param>
        /// <param name="table">The Table that contains the Cell</param>
        /// <param name="cellPos">A CellPos representing the position of the Cell</param>
        /// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
        /// <param name="userSetEditorValues">Specifies whether the ICellEditors 
        /// starting value has already been set by the user</param>
        /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
        public virtual bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            this.cell = cell;
            this.table = table;
            this.cellPos = cellPos;
            this.cellRect = cellRect;

            // check if the user has already set the editors value for us
            if (!userSetEditorValues)
            {
                this.SetEditValue();
            }

            this.SetEditLocation(cellRect);

            // raise the BeginEdit event
            var e = new CellEditEventArgs(cell, this, table, cellPos.Row, cellPos.Column, cellRect)
                        {
                            Handled = userSetEditorValues
                        };

            this.OnBeginEdit(e);

            // if the edit has been canceled, remove the editor and return false
            if (e.Cancel)
            {
                this.RemoveEditControl();
                return false;
            }

            return true;
        }
Пример #3
0
        /// <summary>
        /// Stops editing the Cell and commits any changes
        /// </summary>
        public virtual void StopEditing()
        {
            Application.RemoveMessageFilter(this.keyMessageFilter);
            Application.RemoveMessageFilter(this.mouseMessageFilter);

            var e = new CellEditEventArgs(this.cell, this, this.table, this.cellPos.Row, this.cellPos.Column, this.cellRect);

            this.table.OnEditingStopping(e);
            this.OnEndEdit(e);

            if (!e.Cancel && !e.Handled)
            {
                this.SetCellValue();
                this.table.OnEditingStopped(e);
            }

            this.RemoveEditControl();
        }
Пример #4
0
		/// <summary>
		/// Raises the EditingCancelled event
		/// </summary>
		/// <param name="e">A CellEditEventArgs that contains the event data</param>
		protected internal virtual void OnEditingCancelled(CellEditEventArgs e)
		{
			if (this.CanRaiseEvents)
			{
				if (EditingCancelled != null)
				{
					EditingCancelled(e.Cell, e);
				}
			}
		}
Пример #5
0
        /// <summary>
        /// Stops editing the Cell and ignores any changes
        /// </summary>
        public virtual void CancelEditing()
        {
            Application.RemoveMessageFilter(this.keyMessageFilter);
            Application.RemoveMessageFilter(this.mouseMessageFilter);

            var e = new CellEditEventArgs(this.cell, this, this.table, this.cellPos.Row, this.cellPos.Column, this.cellRect);

            this.table.OnEditingCancelled(e);
            this.OnCancelEdit(e);

            this.RemoveEditControl();
        }
Пример #6
0
		/// <summary>
		/// Raises the AfterEditing event
		/// </summary>
		/// <param name="e">A CellEditEventArgs that contains the event data</param>
	    protected internal virtual void OnAfterEditing(CellEditEventArgs e) {
		   if (this.CanRaiseEvents) {
			  if (AfterEditing != null) {
				 AfterEditing(e.Cell, e);
			  }
		   }
	    }
Пример #7
0
		/// <summary>
		/// Starts editing the Cell at the specified CellPos
		/// </summary>
		/// <param name="cellPos">A CellPos that specifies the Cell to be edited</param>
		public void EditCell(CellPos cellPos)
		{
			// don't bother if the cell doesn't exists or the cell's
			// column is not visible or the cell is not editable
			if (!this.IsValidCell(cellPos) || !this.ColumnModel.Columns[cellPos.Column].Visible || !this.IsCellEditable(cellPos))
			{
				return;
			}

			// check if we're currently editing a cell
			if (this.EditingCell != CellPos.Empty)
			{
				// don't bother if we're already editing the cell.  
				// if we're editing a different cell stop editing
				if (this.EditingCell == cellPos)
				{
					return;
				}
				else
				{
					this.EditingCellEditor.StopEditing();
				}
			}

			Cell cell = this.TableModel[cellPos];
			ICellEditor editor = this.ColumnModel.GetCellEditor(cellPos.Column);

			// make sure we have an editor and that the cell 
			// and the cell's column are editable
			if (editor == null || !cell.Editable || !this.ColumnModel.Columns[cellPos.Column].Editable)
			{
				return;
			}

			if (this.EnsureVisible(cellPos))
			{
				this.Refresh();
			}

			Rectangle cellRect = this.CellRect(cellPos);

			// give anyone subscribed to the table's BeginEditing
			// event the first chance to cancel editing
			CellEditEventArgs e = new CellEditEventArgs(cell, editor, this, cellPos.Row, cellPos.Column, cellRect);

			this.OnBeginEditing(e);

			//
			if (!e.Cancel)
			{
				// get the editor ready for editing.  if PrepareForEditing
				// returns false, someone who subscribed to the editors 
				// BeginEdit event has cancelled editing
				if (!editor.PrepareForEditing(cell, this, cellPos, cellRect, e.Handled))
				{
					return;
				}

				// keep track of the editing cell and editor 
				// and start editing
				this.editingCell = cellPos;
				this.curentCellEditor = editor;

				editor.StartEditing();
			}
		}
 void tableList_BeginEditing(object sender, XPTable.Events.CellEditEventArgs e)
 {
     // throw new NotImplementedException();
 }
Пример #9
0
 /// <summary>
 /// Raises the EditingStopping event
 /// </summary>
 /// <param name="e">A CellEditEventArgs that contains the event data</param>
 protected internal virtual void OnEditingStopping(CellEditEventArgs e)
 {
     if (this.CanRaiseEvents)
     {
         if (EditingStopping != null)
         {
             EditingStopping(e.Cell, e);
         }
     }
 }
Пример #10
0
 private void lvwTimeSheet_EditingStopped(object sender, CellEditEventArgs e)
 {
     int row = e.Row;
     double oldValue = GetCellValue(e.Cell.Text);
     double newValue = GetCellValue(((TextCellEditor)e.Editor).TextBox.Text);
     double total = GetCellValue(lvwTimeSheet.TableModel.Rows[row].Cells[35].Text);
     total = total + newValue - oldValue;
     lvwTimeSheet.TableModel.Rows[row].Cells[35].Text = total.ToString();
 }