/// <summary>
        /// Handle the BeginningEdit event so we can possibly prevent editing
        /// or limit to current row being edited
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClassesDataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            // The intention here is to prevent edit mode when double-clicking
            // We only want to allow edit mode when F2 is pressed.
            if (e.EditingEventArgs != null)
            {
                // When attempting edit by double-clicking or entering data, we can detect by looking
                // at the RoutedEvent. If MouseLeftButtonDown or TextInput, we will cancel the edit
                if (e.EditingEventArgs.RoutedEvent.Name.Equals("MouseLeftButtonDown") ||
                    e.EditingEventArgs.RoutedEvent.Name.Equals("TextInput"))
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (!IsInEditMode)
            {
                // set edit mode state
                IsInEditMode       = true;
                _currentEditingRow = e.Row;
            }
            else if (e.Row != _currentEditingRow)
            {
                // cancel all new edits for different rows
                e.Cancel = true;
            }
        }
Esempio n. 2
0
 private void _EditStarting(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.DisplayIndex == AssociatedObject.Columns.Count - 1)
     {
         _monitorForTab = true;
     }
 }
 public virtual void BeginningEditEvent()
 {
     this._cancelCellEvent        = false;
     this._cancelRowEvent         = false;
     this._beginningEditEventArgs = null;
     this._eventCount             = 0;
     EditFirstCell(
         DataGridEditAction.Commit /*cellEditAction*/,
         DataGridEditAction.Commit /*rowEditAction*/,
         new DataGridDelegate(
             delegate(DataGrid dataGrid)
     {
         dataGrid.BeginningEdit       -= new EventHandler <DataGridBeginningEditEventArgs>(dataGrid_BeginningEdit);
         dataGrid.BeginningEdit       += new EventHandler <DataGridBeginningEditEventArgs>(dataGrid_BeginningEdit);
         this._currentCellChangedCount = 0;
         dataGrid.CurrentCellChanged  += new EventHandler <EventArgs>(dataGrid_CurrentCellChanged);
         this._selectionChangedCount   = 0;
         dataGrid.SelectionChanged    += new SelectionChangedEventHandler(dataGrid_SelectionChanged);
     }),
         new DataGridCellValidateDelegate(
             delegate(DataGrid dataGrid, object beforeValue, object afterValue)
     {
         // Ensure that the BeginningEdit event was raised
         Assert.IsNotNull(this._beginningEditEventArgs, "BeginningEdit wasn't raised");
         Assert.AreEqual(1, this._eventCount, "Event was raised too many times");
         Assert.AreEqual(0, this._beginningEditEventArgs.Column.Index, "Incorrect BeginningEdit Column");
         Assert.AreEqual(0, this._beginningEditEventArgs.Row.Index, "Incorrect BeginningEdit Row");
     }),
         new DataGridDelegate(
             delegate(DataGrid dataGrid)
     {
         dataGrid.BeginningEdit -= new EventHandler <DataGridBeginningEditEventArgs>(dataGrid_BeginningEdit);
     }));
     EnqueueTestComplete();
 }
Esempio n. 4
0
 private void dgrid_productos_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (dgrid_productos.SelectedItem == null || (dgrid_productos.SelectedItem as Producto).Codigo == "")
     {
         e.Cancel = true;
     }
 }
Esempio n. 5
0
 public void OnBeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.SortMemberPath == "PARAMETER_CD")
     {
         oldParameterCD = ((System.Data.DataRowView)(e.Row.Item)).Row["PARAMETER_CD"].ToString();
     }
 }
Esempio n. 6
0
 private void DataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.GetType() == typeof(DataGridCheckBoxColumn))
     {
         ((ViewModels.StringConstants)DataContext).IsEdited = true;
     }
 }
        private void DataGrid_Standard_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            if (!IsEditingRow)
            {
                // set edit mode state
                IsEditingRow       = true;
                _currentEditingRow = e.Row;
                _currentObject     = CurrentItem;

                IEnumerable <DataGridRow> rows = GetDataGridRows(this);
                foreach (DataGridRow row in rows)
                {
                    if (row != _currentEditingRow)
                    {
                        row.IsEnabled  = false;
                        row.Background = SystemColors.InactiveBorderBrush;
                    }
                }
                GridIsModified = true;
            }
            else if (e.Row != _currentEditingRow)
            {
                // cancel all new edits for different rows
                e.Cancel = true;
            }
        }
Esempio n. 8
0
 private void DataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.GetCellContent(e.Row) is TextBlock block)
     {
         LastValue = block?.Text ?? "";
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Valida antes de iniciar la edición
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 12/07/2016
        /// </history>
        private void dgr_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            var grid = (DataGrid)sender;

            if (!GridHelper.IsInEditMode(sender as DataGrid))
            {
                switch (e.Column.SortMemberPath)
                {
                case "GiftItem.giN":
                {
                    GiftPackageItem giftPackageItem = (GiftPackageItem)e.Row.Item;
                    if (giftPackageItem.gpQty < 1)
                    {
                        e.Cancel = true;
                        UIHelper.ShowMessage("Quantity can not be lower than 1.");
                        grid.CurrentCell    = new DataGridCellInfo(grid.SelectedItem, grid.Columns[0]);
                        grid.BeginningEdit -= dgr_BeginningEdit;
                        grid.BeginEdit();
                        grid.BeginningEdit += dgr_BeginningEdit;
                    }
                    break;
                }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Esempio n. 10
0
        private void TargetsDataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            Target dataRow = e.Row.Item as Target;

            mameTargetGBTemp = dataRow.NameTarget;
            // MessageBox.Show(dataRow.NameTarget);
        }
Esempio n. 11
0
 private void DataBackups_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.Header.ToString().Equals("SaveDate") || e.Column.Header.ToString().Equals("Active"))
     {
         e.Cancel = true;
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Here we launch the custom tag editor in a popup
        /// </summary>
        private void TradesGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            if ((string)e.Column.Header == "Tags")
            {
                //make sure the popup isn't too big, otherwise items can be hidden in small resolutions
                TagPickerPopup.Height = Math.Min(600, TradesGrid.ActualHeight - 100);

                //Fill it
                TagPickerPopupListBox.ItemsSource = ViewModel.Data
                                                    .Tags
                                                    .OrderBy(x => x.Name)
                                                    .ToList()
                                                    .Select(
                    x => new CheckListItem <Tag>(x))
                                                    .ToList();

                var trade = (Trade)TradesGrid.SelectedItem;

                if (trade.Tags != null)
                {
                    foreach (CheckListItem <Tag> item in TagPickerPopupListBox.Items)
                    {
                        item.IsChecked = trade.Tags.Contains(item.Item);
                    }
                }

                //and open it at the right position
                TagPickerPopup.PlacementTarget = TradesGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex);
                TagPickerPopup.IsOpen          = true;
            }
        }
Esempio n. 13
0
        void OnBeginEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            var item         = e.Row.Item;
            var propertyName = ((Binding)((DataGridBoundColumn)e.Column).Binding).Path.Path;

            originalText = (string)item.GetType().GetProperty(propertyName).GetValue(item);
        }
        void dataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            DataGrid dataGrid = sender as DataGrid;

            Assert.IsNotNull(dataGrid);
            this._beginningEditEventArgs = e;
            this._eventCount++;
        }
Esempio n. 15
0
        private void countGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            Attendance temp = (Attendance)e.Row.Item;

            oldBegAmount = temp.Count_beg;
            oldMedAmount = temp.Count_mid;
            oldEndAmount = temp.Count_end;
        }
Esempio n. 16
0
        private void dgObat_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            DataGridCell cell = DataGridHelper.GetCell(dgObat, dgObat.SelectedIndex, 2);
            TextBlock    tb   = cell.Content as TextBlock;

            tempStokEdit = int.Parse(tb.Text);
            //MessageBox.Show(value);
        }
        private void Selections_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            DataGrid dg = sender as DataGrid;

            ChoiceScorer.Selection selection = e.Row.Item as ChoiceScorer.Selection;

            int index = dg.Items.IndexOf(selection);
        }
Esempio n. 18
0
        /// <summary>
        ///    Called when the user is beginning the edition of a cell in the <see cref="DataGrid"/> of registered
        ///    addresses.
        /// </summary>
        /// <param name="sender">The object which sent the event.</param>
        /// <param name="e">Holds data about the event.</param>
        private void DataGridCellEditBeginning(object sender, DataGridBeginningEditEventArgs e)
        {
            // Mark the address as "being edited", preventing the "automatic refreshment" routine from
            // overwriting this value while it is being edited.
            AddressData editedData = ((AddressData)e.Row.Item);

            editedData.IsValueBeingEdited = true;
        }
Esempio n. 19
0
 private void Dg_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.Header.Equals("ID"))
     {
         MessageBox.Show("请不要轻易直接修改武将ID,如其他相关编号未修改完全很可能造成跳出");
         oldID = int.Parse((e.Column.GetCellContent(e.Row) as TextBlock).Text);
     }
 }
Esempio n. 20
0
        private void DtGridView_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            frmEditUser edit = new frmEditUser();

            //edit.user = obj

            edit.ShowDialog();
        }
 private void DetailGrid_OnBeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     var viewModel = (PurchaseOrderRequestViewModel)DataContext;
     //if (viewModel.SelectedPaymentRow.Status)
     //{
     //    e.Cancel = true;
     //}
 }
Esempio n. 22
0
 void OnBeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (_changingEditingState)
     {
         return;
     }
     EditingStateBinding.EditingState = EditingState.Editing;
 }
Esempio n. 23
0
 /**<summary>记录重命名前状态</summary>**/
 private void FileList_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Row.Item is AFile file)
     {
         EditingFile = file;
         OldName     = EditingFile.Name;
     }
 }
Esempio n. 24
0
        private async void dataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            var id           = (e.Row.Item as UserModel).Id;
            var UserEditIndo = await new DataController().GetUserInfo(id);

            new AddEditUser(this, UserEditIndo).Show();
            this.Hide();
        }
        /// <summary>
        /// 事件一:当单元给被编辑时;
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CustomerDataGrid_AddEvent_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            Console.WriteLine("开始编辑单元格;函数参数e反馈的实体是单元格内数据类型:" + (e.Column.GetCellContent(e.Row)).DataContext.GetType());

            DataGridWithEvent callbacktemp = e.Column.GetCellContent(e.Row).DataContext as DataGridWithEvent;   // 获取了填写单元格的类型实例;

            callbacktemp.JudegePropertyCall_CellEditing(e.Column.Header as string);
        }
Esempio n. 26
0
 void CustomGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     //done here since when row enters edit mode, the textblock cannot capture the mouseup event
     mouseDown = false;
     clearAllSelection();
     //track the original value of this item before it is edited
     TrackItem(this.SelectedItem);
 }
Esempio n. 27
0
 private static void GridBeginEditFunc(object sender, DataGridBeginningEditEventArgs e)
 {
     if (e.Column.DisplayIndex > 0) //第0列即使进入编辑状态,TextBlock也不能编辑
     {
         e.Cancel = true;
         return;
     }
 }
Esempio n. 28
0
 private void RowBeginEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     DataLayer.EmployeeAccount ne = (DataLayer.EmployeeAccount)e.Row.Item;
     if (ne?.AccountId == 0 && ne.Account == null)
     {
         ne.Account = new Account();
     }
 }
Esempio n. 29
0
 /// <summary>
 /// 单元格获得焦点进入编辑状态时触发的事件
 /// 备注:如果单元格的值为空或者值不属于下拉框中的任何一项,则不会触发TextChanged和SelectionChanged
 /// </summary>
 private void Datagrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
 {
     if (this.dataGrid.SelectedIndex > -1)
     {
         DataGridCellInfo curCellInfo = this.dataGrid.CurrentCell;
         this.isFirstIntoDataCell = true;
     }
 }
Esempio n. 30
0
        //------------------------------------------------------------------------


        private void dataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            IsEditing = true;
            if (IsDragging)
            {
                ResetDragDrop();
            }
        }
Esempio n. 31
0
        private void dgPassenger_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {

        }
Esempio n. 32
0
        /// <summary>
        ///     Called just before a cell will change to edit mode
        ///     to all subclasses to prevent the cell from entering edit mode.
        /// </summary>
        /// <remarks>
        ///     Default implementation raises the BeginningEdit event.
        /// </remarks>
        protected virtual void OnBeginningEdit(DataGridBeginningEditEventArgs e)
        {
            if (BeginningEdit != null)
            {
                BeginningEdit(this, e);
            }

            if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked))
            {
                DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer;
                if (peer != null)
                {
                    peer.RaiseAutomationCellInvokeEvents(e.Column, e.Row);
                }
            }
        }
Esempio n. 33
0
        /// <summary>
        ///     Invoked when the BeginEdit command is executed.
        /// </summary>
        protected virtual void OnExecutedBeginEdit(ExecutedRoutedEventArgs e)
        {
            DataGridCell cell = CurrentCellContainer;
            if ((cell != null) && !cell.IsReadOnly && !cell.IsEditing)
            {
                bool addedPlaceholder = false;
                bool deselectedPlaceholder = false;
                bool reselectPlaceholderCells = false;
                List<int> columnIndexRanges = null;
                int newItemIndex = -1;
                object newItem = null;
                bool placeholderAtBeginning = (EditableItems.NewItemPlaceholderPosition == NewItemPlaceholderPosition.AtBeginning);

                if (IsNewItemPlaceholder(cell.RowDataItem))
                {
                    // If editing the new item placeholder, then create a new item and edit that instead.
                    if (SelectedItems.Contains(CollectionView.NewItemPlaceholder))
                    {
                        // Unselect the NewItemPlaceholder and select the new row
                        UnselectItem(CollectionView.NewItemPlaceholder);
                        deselectedPlaceholder = true;
                    }
                    else
                    {
                        // Cells will automatically unselect when the new item placeholder is removed, but we
                        // should reselect them on the new item.
                        newItemIndex = Items.IndexOf(cell.RowDataItem);
                        reselectPlaceholderCells = ((newItemIndex >= 0) && _selectedCells.Intersects(newItemIndex, out columnIndexRanges));
                    }

                    newItem = AddNewItem();
                    CurrentItem = newItem; // Puts focus on the added row
                    cell = CurrentCellContainer;
                    if (CurrentCellContainer == null)
                    {
                        // CurrentCellContainer becomes null if focus moves out of the datagrid
                        // Calling UpdateLayout instantiates the CurrentCellContainer
                        UpdateLayout();
                        cell = CurrentCellContainer;
                        if ((cell != null) && !cell.IsKeyboardFocusWithin)
                        {
                            cell.Focus();
                        }
                    }

                    if (deselectedPlaceholder)
                    {
                        // Re-select the new item if the placeholder was selected before
                        SelectItem(newItem);
                    }
                    else if (reselectPlaceholderCells)
                    {
                        // Re-select placeholder cells if they were selected before
                        using (UpdateSelectedCells())
                        {
                            int rowIndex = newItemIndex;

                            // When the placeholder is at the beginning, we don't hide it, so those cells need to be unselected.
                            // The cells to select are also now one row below.
                            if (placeholderAtBeginning)
                            {
                                _selectedCells.RemoveRegion(newItemIndex, 0, 1, Columns.Count);
                                rowIndex++;
                            }

                            for (int i = 0, count = columnIndexRanges.Count; i < count; i += 2)
                            {
                                _selectedCells.AddRegion(rowIndex, columnIndexRanges[i], 1, columnIndexRanges[i + 1]);
                            }
                        }
                    }

                    addedPlaceholder = true;
                }

                RoutedEventArgs editingEventArgs = e.Parameter as RoutedEventArgs;
                DataGridBeginningEditEventArgs beginningEditEventArgs = null;

                if (cell != null)
                {
                    // Give the callback an opportunity to cancel edit mode
                    beginningEditEventArgs = new DataGridBeginningEditEventArgs(cell.Column, cell.RowOwner, editingEventArgs);
                    OnBeginningEdit(beginningEditEventArgs);
                }

                if ((cell == null) || beginningEditEventArgs.Cancel)
                {
                    // If CurrentCellContainer is null then cancel editing
                    if (deselectedPlaceholder)
                    {
                        // If the new item placeholder was deselected and the new item was selected,
                        // de-select the new item. Selecting the new item placeholder comes at the end.
                        // This is to accomodate the scenario where the new item placeholder only appears
                        // when not editing a new item.
                        UnselectItem(newItem);
                    }
                    else if (reselectPlaceholderCells && placeholderAtBeginning)
                    {
                        // When the placeholder is at the beginning, we need to unselect the added item cells.
                        _selectedCells.RemoveRegion(newItemIndex + 1, 0, 1, Columns.Count);
                    }

                    if (addedPlaceholder)
                    {
                        // The edit was canceled, cancel the new item
                        CancelRowItem();

                        // Display the new item placeholder again
                        UpdateNewItemPlaceholder(/* isAddingNewItem = */ false);

                        // Put focus back on the placeholder
                        SetCurrentItemToPlaceholder();
                    }

                    if (deselectedPlaceholder)
                    {
                        // If the new item placeholder was deselected, then select it again.
                        SelectItem(CollectionView.NewItemPlaceholder);
                    }
                    else if (reselectPlaceholderCells)
                    {
                        for (int i = 0, count = columnIndexRanges.Count; i < count; i += 2)
                        {
                            _selectedCells.AddRegion(newItemIndex, columnIndexRanges[i], 1, columnIndexRanges[i + 1]);
                        }
                    }
                }
                else
                {
                    if (!addedPlaceholder && !IsEditingRowItem)
                    {
                        EditRowItem(cell.RowDataItem);
                        
                        var bindingGroup = cell.RowOwner.BindingGroup;
                        if (bindingGroup != null)
                        {
                            bindingGroup.BeginEdit();
                        }

                        _editingRowItem = cell.RowDataItem;
                        _editingRowIndex = Items.IndexOf(_editingRowItem);
                    }

                    cell.BeginEdit(editingEventArgs);
                    cell.RowOwner.IsEditing = true;
                }
            }

            // CancelEdit and CommitEdit rely on IsAddingNewItem and IsEditingRowItem
            CommandManager.InvalidateRequerySuggested();

            e.Handled = true;
        }
Esempio n. 34
0
		void BookmarkList_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
		{
			is_editing = true;
		}
		/// <summary>
		/// Checks for FeatureLayer restrictions and cancels the edit if FeatureLayer, 
		/// EditorTracking or Field indicate that and edit is not allowed.
		/// </summary>		
		/// <param name="e">The event data.</param>
		protected override void OnBeginningEdit(DataGridBeginningEditEventArgs e)
		{
#if SILVERLIGHT
			bool isFeatureReadOnly;
			if (featureLayer != null)
			{
				isFeatureReadOnly = featureLayer.IsReadOnly;				
			}
			else
				isFeatureReadOnly = false;

			if (!isFeatureReadOnly)
			{
				// Verify whether cell's associated attribute is editable:
				Field associatedField = e.Column.GetValue(FieldColumnProperty) as Field;
				object rowDataContext = e.Row.DataContext;
				if (rowDataContext != null && associatedField != null)
				{
					System.Reflection.PropertyInfo propertyInfo = rowDataContext.GetType().GetProperty(associatedField.Name);
					if (propertyInfo != null)
					{
						object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(EditableAttribute), true);
						if (customAttributes != null && customAttributes.Length > 0)
						{
							EditableAttribute editableAttribute = customAttributes[0] as EditableAttribute;
							if (editableAttribute != null && !editableAttribute.AllowEdit)
							{
								e.Cancel = true;    // Cell (attribute) is readonly
								return;
							}
						}
					}
				}

				// The attribute is editable:
				base.OnBeginningEdit(e);
			}
			else
				e.Cancel = true;
#else
			if (featureLayer != null)
			{
				// Check layer to see if it is read-only.
				e.Cancel = featureLayer.IsReadOnly;
				if (e.Cancel)
					return;				

				// Check (Attribute/Column) to see if it is read-only.
				Field field = e.Column.GetValue(FieldColumnProperty) as Field;
				e.Cancel = !field.Editable;
				if (e.Cancel)
					return;
			}
			base.OnBeginningEdit(e);
#endif
		}