private List<object> GetCurrentRow(DataGridCellEditEndingEventArgs e) { List<object> values = new List<object>(); foreach (object item in (MainDataGrid.SelectedItem as DataRowView).Row.ItemArray) { values.Add(item); } string name = e.Column.Header.ToString(); string value = (e.EditingElement as TextBox).Text; for (int i = 0; i < MainDataGrid.Columns.Count; i++) { if (MainDataGrid.Columns[i].Header.ToString() == name) { values[i] = value; break; } } return values; }
private void DataGridInventario_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { var columna = e.Column as DataGridBoundColumn; if (columna != null) { var bindingPath = (columna.Binding as Binding).Path.Path; if (bindingPath == "noExistencias") { var celdaEditada = e.EditingElement as TextBox; if (celdaEditada.Text.Contains(" ")) { FuncionesComunes.MostrarMensajeDeError("No se han guardado los cambios.\n No se aceptan espacios vacios."); } else { Provision provisionEditada = dataGridInventario.SelectedCells[0].Item as Provision; provisionEditada.activado = true; provisionEditada.noExistencias = FuncionesComunes.ParsearAEntero(celdaEditada.Text); contexto = new InstanceContext(this); EditarIngredienteClient serverEditarIngrediente = new EditarIngredienteClient(contexto); serverEditarIngrediente.Editar(provisionEditada); } } } } }
private void FileRegister_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { var editingTextBox = e.EditingElement as TextBox; string newValue = editingTextBox.Text; if (e.EditAction == DataGridEditAction.Commit) { if (newValue.Length <= 2) { try { byte b = (byte)int.Parse(newValue, System.Globalization.NumberStyles.HexNumber); editingTextBox.Text = b.ToString("X2"); regArrayHandler.setRegArray((uint)(e.Row.GetIndex() * 8 + e.Column.DisplayIndex), b); UpdateSFR(); UpdateFileRegisterUI(); UpdatePin(); } catch { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); MessageBox.Show("Invalid hexadecimal value", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); MessageBox.Show("Only one hexadecimal byte allowed", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
void _CheckInPrice(BaseCar car, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { // var column = e.Column as DataGridBoundColumn; // if (column != null) // { // var t = (column.Binding as Binding); // var bindingPath = t.Path.Path; // if (bindingPath == "Col2") // { // int rowIndex = e.Row.GetIndex(); // var el = e.EditingElement as TextBox; // // rowIndex has the row index // // bindingPath has the column's binding // // el.Text has the new, user-entered value // } // else // { // // Тут уже фильтруем по значениеям // MessageBox.Show(t.Path.PathParameters.ToString()); // } // } _RecomputePrice_Copy(); } }
private void SubjectTeacher_DG_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.Column is DataGridTemplateColumn) { BindingOperations.ClearAllBindings(e.EditingElement as ContentPresenter); } }
protected override void OnCellEditEnding(DataGridCellEditEndingEventArgs e) { continueEdit = e.EditAction == DataGridEditAction.Commit; Log.DebugFormat("OnCellEditEnding(EditAction = {0})", e.EditAction); Log.DebugFormat(" continueEdit={0}, isNewItem={1}", continueEdit, isNewItemForContinueEdit); base.OnCellEditEnding(e); }
/// <summary> /// Read Data entered in each Cell /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgEmp_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { FrameworkElement eleEno = dgEmp.Columns[0].GetCellContent(e.Row); if (eleEno.GetType() == typeof(TextBox)) { emp.EmpNo = Convert.ToInt32(((TextBox)eleEno).Text); } FrameworkElement eleEname = dgEmp.Columns[1].GetCellContent(e.Row); if (eleEname.GetType() == typeof(TextBox)) { emp.EmpName = ((TextBox)eleEname).Text; } FrameworkElement eleSal = dgEmp.Columns[2].GetCellContent(e.Row); if (eleSal.GetType() == typeof(TextBox)) { emp.Salary = Convert.ToInt32(((TextBox)eleSal).Text); } FrameworkElement eleDname = dgEmp.Columns[3].GetCellContent(e.Row); if (eleDname.GetType() == typeof(TextBox)) { emp.DeptName = ((TextBox)eleDname).Text; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void check_list_DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { try { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); if (e.EditAction == DataGridEditAction.Commit && this.checkListSearchedClient != null) { this.checkListSearchedClient.CheckListRows[e.Row.GetIndex()] = e.Row.DataContext as CheckListRow; Type checkListRowType = typeof(CheckListRow); checkListRowType.GetProperty(e.Column.SortMemberPath).SetValue(this.checkListSearchedClient.CheckListRows[e.Row.GetIndex()], ((TextBox)e.EditingElement).Text); clientDAO.UpdateClient(this.checkListSearchedClient); } DisplaySnackbar("הנתונים נשמרו בהצלחה"); } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
private void productSaleOrderGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { DataGrid grid = (DataGrid)sender; Popup productSelector = (Popup)grid.FindName("productSelector"); productSelector.IsOpen = false; }
private void DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { _CheckInPrice(dataGrid_Copy.SelectedItem as BaseCar, e); _RecomputePrice(); _RecomputePrice_Copy(); }
private void ipcs_settings_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (btn_ok != null) { btn_ok.IsEnabled = true; } }
private void DataGrid_Update_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { try { string editTex = ((TextBox)e.EditingElement).Text; PatientCategories patientCategories = ((FrameworkElement)e.Row).DataContext as PatientCategories; if (!patientCategories.PatientCategory_Title.Equals(editTex)) { if (MessageBox.Show("確定將<" + patientCategories.PatientCategory_Title + ">修改為<" + editTex + ">?\r\n如果是的話,所有擁有此分類的病患分類也會被更動", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { PatientCategories updateItem = (from pc in dde.PatientCategories where pc.PatientCategory_ID == patientCategories.PatientCategory_ID select pc).First(); updateItem.PatientCategory_Title = editTex; dde.SaveChanges(); } else { pcvm.PatientCategories = dde.PatientCategories.ToList(); } } } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); } }
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.EditingElement is TextBox) { ((TextBox)e.EditingElement).Text = ((TextBox)e.EditingElement).Text.Replace("\b", ""); } }
private void check_showDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { }
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (count != standard.Subjects.Count) { count = standard.Subjects.Count; Analyse(); } }
private void ColumnListBox_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.Column.Header as String == "EnumName") { var tx = e.EditingElement as TextBox; this.SetEnumNameToStoredProcedure(tx.Text); } }
void dg_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { var fff= e.Column.GetCellContent(e.Row); if (fff != null && fff.BindingGroup != null && fff.BindingGroup.Items.Count > 0) { bool flag= fff.BindingGroup.CommitEdit(); Console.WriteLine(flag); } }
private void GridOnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (_displayIndexCommiting) return; if (!ReferenceEquals(e.Column, ColumnDisplayIndex)) return; if (e.EditAction != DataGridEditAction.Commit) return; _displayIndexCommiting = true; bool commited = Grid.CommitEdit(DataGridEditingUnit.Row, true); _displayIndexCommiting = false; if (!commited) return; var editedItem = (GridColumnSettings)e.Row.Item; _newDisplayIndex = editedItem.DisplayIndex; if (_newDisplayIndex < 0) { _newDisplayIndex = 0; editedItem.DisplayIndex = _newDisplayIndex; } else if (_newDisplayIndex >= Grid.Items.Count) { _newDisplayIndex = Grid.Items.Count - 1; editedItem.DisplayIndex = _newDisplayIndex; } if (_oldDisplayIndex < _newDisplayIndex) { foreach (GridColumnSettings item in Grid.Items) { if (ReferenceEquals(item, editedItem)) continue; if (item.DisplayIndex >= _oldDisplayIndex + 1 && item.DisplayIndex <= _newDisplayIndex) item.DisplayIndex -= 1; } } else { foreach (GridColumnSettings item in Grid.Items) { if (ReferenceEquals(item, editedItem)) continue; if (item.DisplayIndex >= _newDisplayIndex && item.DisplayIndex <= _oldDisplayIndex - 1) item.DisplayIndex += 1; } } Grid.UpdateTarget(ItemsControl.ItemsSourceProperty); }
private void employeeDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { var employee = e.Row.Item as Employee; if (employee != null) { switch (e.Column.Header.ToString()) { case "First Name": { var textBox = e.EditingElement as TextBox; employee.FirstName = textBox.Text; break; } case "Last Name": { var textBox = e.EditingElement as TextBox; employee.LastName = textBox.Text; break; } case "Email": { var textBox = e.EditingElement as TextBox; if (Regex.IsMatch(textBox.Text, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", RegexOptions.IgnoreCase)) { employee.Email = textBox.Text; } else { MessageBox.Show("Invalid email fromat!"); textBox.Text = employee.Email; } break; } case "Birth Date": { var datePicker = VisualTreeHelper.GetChild(e.EditingElement, 0) as DatePicker; if (datePicker.SelectedDate < DateTime.Now && datePicker.SelectedDate != null) { employee.BirthDate = (DateTime)datePicker.SelectedDate; } else { MessageBox.Show("Invalid date provided!"); datePicker.SelectedDate = employee.BirthDate; } break; } default: break; } } }
private void StreamDG_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { DataRowView rowView = e.Row.Item as DataRowView; rowBeingEdited = rowView; if (e.Column is DataGridTemplateColumn) { BindingOperations.ClearAllBindings(e.EditingElement as ContentPresenter); } }
private void infoGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { string newData = ((TextBox)e.EditingElement).Text; var col = infoGrid.CurrentCell.Column.DisplayIndex; var rowChange = infoGrid.SelectedItems[0] as DataRowView; rowChange.Row.BeginEdit(); rowChange[col] = newData; rowChange.Row.EndEdit(); }
private void LinkDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { var textBox = (TextBox)e.EditingElement; var composition = (Composition)DataContext; var url = textBox.Text; var link = (Link)textBox.DataContext; link.Compositions.Add(composition); link.Name = UrlToTitleConverter.UrlToTitle(url); }
private void dgSpares_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { HandleMainDataGridCellEditEnding(sender, e); SpareView sv = (SpareView)e.Row.DataContext; if (sv.id > 0) if (sv.q_demand.HasValue) { sv.demand = (int)sv.q_demand - (int)sv.QRest; if (sv.demand < 0) sv.demand = 0; } }
/// <summary> /// Update the description in database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PPTableJobListDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { if (e.EditAction == DataGridEditAction.Commit && e.Column is DataGridTextColumn) { var item = e.Row.Item as JobListItemVm; var val = (e.EditingElement as TextBox).Text; item.UpdateDescription(val); } } catch { } }
private void grdMain_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Cancel) { return; } var item = (e.Row.Item as ParameterData); if (item.SystemDefault && e.Column.Header.ToString() == "Name") { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); } }
private void GroupList_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { var info = GroupList.SelectedItem as Group.Info; if (e.Column.Header.ToString() == "좌표") { var txt = e.EditingElement as TextBox; if (txt.Text != "") { info.coordinate = Point.Parse(txt.Text); } } if (addedList.Contains(info) == false && changedList.Contains(info) == false) { changedList.Add(info); } }
private void dataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (!e.Column.Header.Equals("Valmistusmaa")) { return; } if (!recursion) { recursion = true; dataGrid.CommitEdit(DataGridEditingUnit.Row, true); recursion = false; UpdateComboBox(); } }
private void DG_ASN_GR_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { string GRLineNo = ""; var i = DG_ASN_GR.SelectedItem; var b = i as DataRowView; if (b != null) { GRLineNo = b.Row[0].ToString(); //取得GR表中主键 } //单元格动态取值 /*var cell = DG_ASN_GR.CurrentCell; DataRowView item = cell.Item as DataRowView; if (item != null) { item[cell.Column.DisplayIndex].ToString(); }*/ next_cell_value= (e.Column.GetCellContent(e.Row) as TextBox).Text; if (pre_cell_value != next_cell_value) { //判断是否是product单元格更改,column index应该是2; if (DG_ASN_GR.CurrentColumn.DisplayIndex == 2) { if(Global.VerifyProductCode(next_cell_value,Global.strCustomerCode) != null) { //如果匹配 bool result=ASNDAL.UpdateASNGR(GRLineNo, "product_code",next_cell_value); MessageBox.Show(result.ToString()); } else { //如果更改后产品代码不存在数据库中 MessageBox.Show(Global.strCustomerName+"中"+next_cell_value+"不存在。请注意输入正确的产品代码。"); //还原更改前的数值 (e.Column.GetCellContent(e.Row) as TextBox).Text = pre_cell_value; } } } }
private void dgWorkers_CellEditEnding_1(object sender, DataGridCellEditEndingEventArgs e) { Action action = delegate { int index = dgWorkers.Items.IndexOf(dgWorkers.CurrentItem); Worker wkr = e.Row.Item as Worker; bool updateRes = _repo.Update(wkr); if (updateRes) { MessageBox.Show(wkr.ToString() + "\r\r was update" , "Update"); } }; Dispatcher.BeginInvoke(action, System.Windows.Threading.DispatcherPriority.Background); }
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (((dataGrid.SelectedItem as Variable).Value != int.Parse((e.EditingElement as TextBox).Text)) && MessageBox.Show(App.Current.TryFindResource("delconfirmation").ToString() + "", App.Current.TryFindResource("save").ToString(), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { try { int value = int.Parse((e.EditingElement as TextBox).Text); SQLiteHelper.GetSqlHelper.UpdateVariable((dataGrid.SelectedItem as Variable).Name, value); } catch { MessageBox.Show(App.Current.TryFindResource("valueint").ToString()); } } SetVariables(); }
private void BackupsDataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { String oldName = backups[e.Row.GetIndex()].BackupName; var tb = e.EditingElement as System.Windows.Controls.TextBox; String newName = tb.Text; try { if (!oldName.Equals(newName)) { Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(backupsDirectory + directorySeparator + oldName + ".zip", newName + ".zip"); } }catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); tb.Text = oldName; } }
private void dg_CellEditEnding_1(object sender, DataGridCellEditEndingEventArgs e) { string header = e.Column.Header.ToString(); if (header.Equals("Stock id")) { ComboBox c = e.EditingElement as ComboBox; STOCK record = (from s in context.STOCKs where c.Text.ToString() == s.STOCK_ID select s).FirstOrDefault(); } else if (header.Equals("QTY")) { TextBox t = e.EditingElement as TextBox; MessageBox.Show(t.Text); } //string v= ((ComboBox)(dg.Columns[0].GetCellContent((STOCK)dg.Items[0]))).SelectedValue.ToString(); //MessageBox.Show(v); }
private void dgrPoints_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { if (isEditEnding) { return; } try { isEditEnding = true; MessageBoxResult mr = MessageBox.Show("Сохранить изменения?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Question); if (mr == MessageBoxResult.No) { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); } } finally { isEditEnding = false; } }
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { // Get the data as a text from TextBox TextBox t = e.EditingElement as TextBox; DataRowView row = (DataRowView)dataGrid.SelectedItems[0]; // Update Song based on selected Column Song song = musicLib.GetSong(Int32.Parse(row["Id"] as String)); string col = e.Column.Header as String; switch (col) { case "Title": song.Title = t.Text; break; case "Artist": song.Artist = t.Text; break; case "Album": song.Album = t.Text; break; case "Genre": song.Genre = t.Text; break; } musicLib.UpdateSong(song.Id, song); musicLib.Save(); }
private void sTOCKDataGrid_CellEditEnding_1(object sender, DataGridCellEditEndingEventArgs e) { STOCK stock = (STOCK)e.Row.Item; var id = stock.ID; TextBox t = e.EditingElement as TextBox; String header = e.Column.Header.ToString(); Al_MujahidEntities ctx = new Al_MujahidEntities(); if (header.Equals("PRICE")) { STOCK record = (from u in ctx.STOCKs where u.ID == id select u).FirstOrDefault(); record.PRICE = Convert.ToDecimal(t.Text.ToString()); }else if(header.Equals("ID")) { MessageBox.Show("Cant Modify ID"); }else if(header.Equals("STOCK_ID")) { STOCK record = (from u in ctx.STOCKs where u.ID == id select u).FirstOrDefault(); record.STOCK_ID = t.Text.ToString(); }else if(header.Equals("QTY")) { STOCK record = (from u in ctx.STOCKs where u.ID == id select u).FirstOrDefault(); record.QTY = Convert.ToInt32(t.Text.ToString()); }else if(header.Equals("NAME")) { STOCK record = (from u in ctx.STOCKs where u.ID == id select u).FirstOrDefault(); record.NAME = t.Text.ToString(); } ctx.SaveChanges(); // Stock_Load(); // will change it if inefficient for large records // sTOCKDataGrid.IsReadOnly = true; }
private void Overall_DG_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.Column.Header.ToString().ToLower() != "from") return; if (e.Row.GetIndex() == 11) { MySQLHandler.OverallGrade.Default.Dt.Rows[11]["lower_bound"] = 0; return; } int new_value =Convert.ToInt32((e.EditingElement as MahApps.Metro.Controls.NumericUpDown).Value); var obj=MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex()]["upper_bound"]; if(obj==DBNull.Value) obj=0; int upper_value=Convert.ToInt32(obj); string error = ""; if (new_value <0 || new_value >100) { error = "Value can not be negative nor above 100."; } if (new_value > upper_value) { error+=" Value can not be greater than upper boundary."; } if (!String.IsNullOrWhiteSpace(error)) { MessageBox.Show(error); if (upper_value == 0) MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex()]["lower_bound"] = DBNull.Value; else MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex()]["lower_bound"] = upper_value; var l_obj = MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex() + 1]["upper_bound"]; if (l_obj == DBNull.Value) { MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex()]["lower_bound"] = DBNull.Value; } else MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex()]["lower_bound"] = Convert.ToInt32(l_obj) + 1; } else { MySQLHandler.OverallGrade.Default.Dt.Rows[e.Row.GetIndex() + 1]["upper_bound"] = new_value - 1; } }
/// <summary> /// Handles user hex edit in fileregister view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FileRegister_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { var editingTextBox = e.EditingElement as TextBox; string newValue = editingTextBox.Text; if (e.EditAction == DataGridEditAction.Commit) { if (newValue.Length <= 2) { try { byte b = (byte)int.Parse(newValue, System.Globalization.NumberStyles.HexNumber); editingTextBox.Text = b.ToString("X2"); int row = e.Row.GetIndex(); int column = e.Column.DisplayIndex; Data.SetRegister((byte)(row * 8 + column), b); UpdateUI(); if (row > 0) { FileRegister.CurrentCell = new DataGridCellInfo(FileRegister.Items[row - 1], FileRegister.Columns[column]); } } catch { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); MessageBox.Show("Invalid hexadecimal value", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { e.Cancel = true; (sender as DataGrid).CancelEdit(DataGridEditingUnit.Cell); MessageBox.Show("Only one hexadecimal byte allowed", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
void CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { int col = -1; for (int i = 0; i < _control.Columns.Count; i++) { if (ReferenceEquals(_control.Columns[i], e.Column)) { col = i; break; } } if (e.EditingElement is TextBox) { AddSentence(new TokenName(), ".EmulateChangeCellText(", _control.SelectedIndex, ", ", col, ", ", GenerateUtility.ToLiteral(((TextBox)e.EditingElement).Text), new TokenAsync(CommaType.Before), ");"); } else if (e.EditingElement is ComboBox) { AddSentence(new TokenName(), ".EmulateChangeCellComboSelect(", _control.SelectedIndex, ", ", col + ", ", ((ComboBox)e.EditingElement).SelectedIndex, new TokenAsync(CommaType.Before), ");"); } else if (e.EditingElement is CheckBox) { bool? val = ((CheckBox)e.EditingElement).IsChecked; string valStr = val.HasValue && val.Value ? "true" : "false"; AddSentence(new TokenName(), ".EmulateCellCheck(", _control.SelectedIndex, ", ", col, ", ", valStr, new TokenAsync(CommaType.Before), ");"); } }
/// <summary> /// Event raised when a cell has finished editing. /// The edited cell is either updated or added to the database. /// TODO: This should be converted to be done by pure binding instead using this event. /// TODO: USE: xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" for binding! /// TODO: USE: xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" for binding! /// </summary> private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { using (var businessContext = new BusinessContext()) { Keyword keyword = (Keyword) e.Row.Item; keyword = businessContext.DataContext.Keywords.Find(keyword.Id); if (keyword != null) { keyword.Name = ((TextBox)e.EditingElement).Text; businessContext.UpdateKeyword(keyword); } else { keyword = new Keyword { Name = ((TextBox)e.EditingElement).Text, LanguageId = ((Language)LanguageTabControl.SelectedValue).Id }; businessContext.AddNewKeyword(keyword); } } }
private void status_DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { try { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); if (e.EditAction == DataGridEditAction.Commit) { Client client = e.Row.DataContext as Client; var comboBox = e.EditingElement as ComboBox; client.StatusValue = comboBox.SelectedValue.ToString(); if (!Enums.CaseStatuses.Any(x => x == client.StatusValue)) { throw new ArgumentException("not valid status"); } clientDAO.UpdateClient(client); } DisplaySnackbar("הנתונים נשמרו בהצלחה"); } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (ArgumentException) { DisplaySnackbar("סטטוס לא קיים במערכת, השינוי לא נשמר אנא נסה סטטוס אחר"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
private void Grid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) dataModified = true; }
/// <summary> /// Retourne sur le champ de détection de code barre /// après édition de la quantité /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GrdLignes_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { //TxtCodeBarre.Focus(); }
private void gameGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { }
protected virtual new void OnCellEditEnding(DataGridCellEditEndingEventArgs e) { }
private void Dg_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { ManagementObjectCollection NACMOC = MC_NAC.GetInstances(); var row = e.Row.GetIndex(); var col = e.Column.DisplayIndex; DataRowView drow = (DataRowView)dg.SelectedItems[0]; foreach (ManagementObject MO in NACMOC) { if (MO["Caption"].ToString() == drow["Caption"].ToString()) { switch (col) { case 4: // IPv4 if ((((TextBox)e.EditingElement).Text == "auto") || (((TextBox)e.EditingElement).Text == "")) { MO.InvokeMethod("EnableDHCP", null, null); } else { var newIP = MO.GetMethodParameters("EnableStatic"); ManagementBaseObject setIP; newIP["IPAddress"] = new string[] { ((TextBox)e.EditingElement).Text }; newIP["SubnetMask"] = new string[] { drow["IPSubnet"].ToString() }; setIP = MO.InvokeMethod("EnableStatic", newIP, null); } break; case 6: // IPSubnet var newSubnet = MO.GetMethodParameters("EnableStatic"); ManagementBaseObject setSubnet; newSubnet["IPAddress"] = new string[] { drow["IPv4"].ToString() }; newSubnet["SubnetMask"] = new string[] { ((TextBox)e.EditingElement).Text }; setSubnet = MO.InvokeMethod("EnableStatic", newSubnet, null); break; case 7: // DefaultIPGateway var newGateway = MO.GetMethodParameters("SetGateways"); ManagementBaseObject setGateway; newGateway["DefaultIPGateway"] = new string[] { ((TextBox)e.EditingElement).Text }; newGateway["GatewayCostMetric"] = new int[] { 1 }; setGateway = MO.InvokeMethod("SetGateways", newGateway, null); break; case 8: // DNSDomain if ((((TextBox)e.EditingElement).Text == "auto") || (((TextBox)e.EditingElement).Text == "")) { var newDNS = MO.GetMethodParameters("SetDNSServerSearchOrder"); ManagementBaseObject setDNS; newDNS["DNSServerSearchOrder"] = null; setDNS = MO.InvokeMethod("SetDNSServerSearchOrder", newDNS, null); } else { var newDNS = MO.GetMethodParameters("SetDNSServerSearchOrder"); ManagementBaseObject setDNS; newDNS["DNSServerSearchOrder"] = new string[] { ((TextBox)e.EditingElement).Text }; setDNS = MO.InvokeMethod("SetDNSServerSearchOrder", newDNS, null); } break; default: break; } ; } } }
private void studentMarksEntryDg_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { DataRowView rowView = e.Row.Item as DataRowView; rowBeingEdited = rowView; }
private void detailGrid_CellValueChanged(object sender, Control.DataGridCellEditEndingEventArgs e) { if (e.EditAction == Control.DataGridEditAction.Commit) { WPFdataGrid.DataGridControl wPFdataGrid = elementHost1.Child as WPFdataGrid.DataGridControl; var dataGridView = wPFdataGrid.grid; Control.DataGridRow dataRow = e.Row as Control.DataGridRow; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(dataRow.Item); Int16.TryParse(properties["CapRate"]?.GetValue(dataRow.Item)?.ToString(), out Int16 CapRate); Int16.TryParse(properties["ExpDrop"]?.GetValue(dataRow.Item)?.ToString(), out Int16 ExpDrop); pokemonCapRate = new PokemonCapRate() { PName = properties["PName"].GetValue(dataRow.Item)?.ToString(), CapRate = CapRate, ExpDrop = ExpDrop }; ValidationContext validate = new ValidationContext(pokemonCapRate, null, null); IList <ValidationResult> errors = new List <ValidationResult>(); if (!Validator.TryValidateObject(pokemonCapRate, validate, errors, true)) { e.Cancel = true; EventArgs.Cancel = true; EventArgs.Error = null; Control.DataErrorValidationRule validationRule = new Control.DataErrorValidationRule(); Control.ValidationError error = new Control.ValidationError(validationRule, dataRow.BindingGroup.BindingExpressions); EventArgs.Error = $"{errors.First().ErrorMessage}"; error.ErrorContent = $"{errors.First().ErrorMessage}"; foreach (ValidationResult result in errors.Skip(1)) { EventArgs.Error += $"\n{result.ErrorMessage}"; error.ErrorContent += $"\n{result.ErrorMessage}"; } foreach (var binding in dataRow.BindingGroup.BindingExpressions) { Control.Validation.MarkInvalid(dataRow.BindingGroup.BindingExpressions.First(), error); } } else { Control.DataErrorValidationRule validationRule = new Control.DataErrorValidationRule(); Control.ValidationError error = new Control.ValidationError(validationRule, dataRow.BindingGroup.BindingExpressions); e.Cancel = false; EventArgs.Cancel = false; error.ErrorContent = null; pokemonCapRates.Add(pokemonCapRate); } } }
private void ResultBlock_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { e.Cancel = true; }
private void PropertyGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { }
private void dataGrid_CellValueChanged(object sender, Control.DataGridCellEditEndingEventArgs e) { if (e.EditAction == Control.DataGridEditAction.Commit) { WPFdataGrid.DataGridControl wPFdataGrid = elementHost1.Child as WPFdataGrid.DataGridControl; var dataGridView = wPFdataGrid.grid; Control.DataGridRow dataRow = e.Row as Control.DataGridRow; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(dataRow.Item); DataGridDetailsPresenter presenter = FindVisualChild <DataGridDetailsPresenter>(dataRow); DataTemplate detail = presenter.ContentTemplate; Int16.TryParse(properties["HP"].GetValue(dataRow.Item).ToString(), out Int16 HP); Int16.TryParse(properties["Attack"].GetValue(dataRow.Item).ToString(), out Int16 Attack); Int16.TryParse(properties["Defense"].GetValue(dataRow.Item).ToString(), out Int16 Defense); Int16.TryParse(properties["SPAttack"].GetValue(dataRow.Item).ToString(), out Int16 SPAttack); Int16.TryParse(properties["SPDefense"].GetValue(dataRow.Item).ToString(), out Int16 SPDefense); Int16.TryParse(properties["Speed"].GetValue(dataRow.Item).ToString(), out Int16 Speed); Int16 CapRate = 0; Int16 ExpDrop = 0; try { Control.DataGrid detailGrid = detail.FindName("details", presenter) as Control.DataGrid; PropertyDescriptorCollection detailProperties = TypeDescriptor.GetProperties(detailGrid.Items.CurrentItem); Int16.TryParse(detailProperties["CapRate"]?.GetValue(detailGrid.Items?.CurrentItem)?.ToString(), out CapRate); Int16.TryParse(detailProperties["ExpDrop"]?.GetValue(detailGrid.Items?.CurrentItem)?.ToString(), out ExpDrop); } catch { using (Pokemon db = new Pokemon()) { try { CapRate = db.PokemonBaseStats.Where(p => p.PName == properties["PName"].GetValue(dataRow.Item).ToString()).Single().PokemonCapRate.CapRate; ExpDrop = db.PokemonBaseStats.Where(p => p.PName == properties["PName"].GetValue(dataRow.Item).ToString()).Single().PokemonCapRate.ExpDrop; } catch { CapRate = 0; ExpDrop = 0; } } } pokemon = new PokemonBaseStat() { PName = properties["PName"].GetValue(dataRow.Item)?.ToString(), HP = HP, Attack = Attack, Defense = Defense, SPAttack = SPAttack, SPDefense = SPDefense, Speed = Speed, Type1 = properties["Type1"].GetValue(dataRow.Item)?.ToString(), Type2 = properties["Type2"].GetValue(dataRow.Item)?.ToString(), PokemonCapRate = new PokemonCapRate() { PName = properties["PName"].GetValue(dataRow.Item)?.ToString(), CapRate = CapRate, ExpDrop = ExpDrop } }; ValidationContext validate = new ValidationContext(pokemon, null, null); IList <ValidationResult> errors = new List <ValidationResult>(); if (!Validator.TryValidateObject(pokemon, validate, errors, true)) { e.Cancel = true; EventArgs.Cancel = true; EventArgs.Error = null; Control.DataErrorValidationRule validationRule = new Control.DataErrorValidationRule(); Control.ValidationError error = new Control.ValidationError(validationRule, dataRow.BindingGroup.BindingExpressions); EventArgs.Error = $"{errors.First().ErrorMessage}"; error.ErrorContent = $"{errors.First().ErrorMessage}"; foreach (ValidationResult result in errors.Skip(1)) { EventArgs.Error += $"\n{result.ErrorMessage}"; error.ErrorContent += $"\n{result.ErrorMessage}"; } foreach (var binding in dataRow.BindingGroup.BindingExpressions) { Control.Validation.MarkInvalid(dataRow.BindingGroup.BindingExpressions.First(), error); } } else { Control.DataErrorValidationRule validationRule = new Control.DataErrorValidationRule(); Control.ValidationError error = new Control.ValidationError(validationRule, dataRow.BindingGroup.BindingExpressions); e.Cancel = false; EventArgs.Cancel = false; error.ErrorContent = null; } } }
private void options_floors_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { var list = (FloorRs)((DataGrid)sender).ItemsSource; if (e.EditAction == DataGridEditAction.Commit) { var txt = (TextBox)e.EditingElement; //list.Add(new FloorR() { txtFloor = txt.Text.Trim() }); _seledtedFloorR.txtFloor = txt.Text.Trim(); } }
private void GrdLignes_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { ((sender as DataGrid).SelectedItem as DocumentLigne).RowChecked = true; }