private void CellValidating(object sender, CurrentCellValidatingEventArgs e) { var curcell = this.AssociatedObject.InternalGrid.CurrentCell; try { if (e.Style.ColumnIndex == ComboBoxIndex) { if (e.NewValue != e.OldValue) { if (string.IsNullOrEmpty(e.NewValue.ToString())) { return; } var curnod = this.AssociatedObject.InternalGrid.GetNodeAtRowIndex(e.Style.RowIndex); if (curnod != null) { if (curnod.HasChildNodes == true) { ChangeProperty(curnod, e.NewValue.ToString(), e); } } this.AssociatedObject.InternalGrid.InvalidateCells(); } } } catch (Exception ex) { if (ex == e.Style.Exception) { MessageBox.Show(ex.Message); } } }
private bool OnValidateIntegerEdit(CurrentCellValidatingEventArgs e) { var integeredit = e.Style.IntegerEdit; if (integeredit.HasMinValue) { if (integeredit.MinValue > Convert.ToInt64(e.NewValue.ToString())) { e.Handled = true; MessageBoxResult result = MessageBox.Show("The value you entered is not valid.", "Sample side Validation", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { return(true); } e.NewValue = e.OldValue; return(false); } } if (integeredit.HasMaxValue) { if (integeredit.MaxValue < Convert.ToInt64(e.NewValue.ToString())) { e.Handled = true; MessageBoxResult result = MessageBox.Show("The value you entered is not valid.", "Sample side Validation", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { return(true); } e.NewValue = e.OldValue; return(false); } } return(false); }
private void ShowDataValidationMsg(CurrentCellValidatingEventArgs e) { MessageBoxResult result; if (!string.IsNullOrEmpty(e.Style.ErrorAlertText)) { result = MessageBox.Show(e.Style.ErrorAlertText, e.Style.ErrorAlartTitle, MessageBoxButton.OKCancel); } else { result = MessageBox.Show("Invalid cell value", "InvalidCellValue", MessageBoxButton.OKCancel); } if (result != MessageBoxResult.OK) { if (e.OldValue != null && !string.IsNullOrEmpty(e.OldValue.ToString())) { e.NewValue = e.OldValue; } else { e.NewValue = null; } } }
private bool OnValidateIntegerEdit(CurrentCellValidatingEventArgs e) { try { //if have the value as empty, then we can’t convert it into int or double if (e.NewValue != null && string.IsNullOrEmpty(e.NewValue.ToString())) { return(false); } var integerEdit = e.Style.IntegerEdit; if (integerEdit.IsScrollingOnCircle) { if (integerEdit.MinValue == integerEdit.MaxValue) { //Not Equal to if (integerEdit.MinValue == Convert.ToDouble(e.NewValue.ToString())) { return(false); } } else { //Not between if ((integerEdit.MinValue < Convert.ToDouble(e.NewValue.ToString())) && integerEdit.MaxValue > Convert.ToDouble(e.NewValue.ToString())) { return(false); } } return(false); } if (integerEdit.HasMinValue && integerEdit.HasMaxValue && integerEdit.MinValue == integerEdit.MaxValue) { if (integerEdit.MinValue == Convert.ToDouble(e.NewValue.ToString())) { return(false); } return(false); } if (integerEdit.HasMinValue) { if (integerEdit.MinValue > Convert.ToDouble(e.NewValue.ToString())) { return(false); } } if (integerEdit.HasMaxValue) { if (integerEdit.MaxValue < Convert.ToDouble(e.NewValue.ToString())) { return(false); } } } catch (Exception) { return(false); } return(false); }
void AssociatedObject_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args) { if (args.Column.MappingName == "BranchId" && Convert.ToDecimal(args.NewValue) <= 0) { args.ErrorMessage = "Invalid code"; args.IsValid = false; } }
/// <summary> /// Occurs when curent cell is validating. /// </summary> private void SfDataGrid1_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args) { if (args.Column.MappingName == "Discount" && Convert.ToDouble(args.NewValue) > 40) { args.ErrorMessage = "Discount should not exceed 40 percent."; args.IsValid = false; } }
private void GridConfig_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) { try { var reflector = this.GridConfig.View.GetPropertyAccessProvider(); int columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex; var rowData = GridConfig.GetRecordAtRowIndex(columnIndex); //{ // dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia"); //carga desde sql // ww.Conexion = SiaWin.Func.DatosEmp(idemp); // ww.idEmp = idemp; // ww.idBod = tx_bodega.Text; // ww.UltBusqueda = ""; // ww.ShowInTaskbar = false; // ww.Owner = Application.Current.MainWindow; // ww.WindowStartupLocation = WindowStartupLocation.CenterScreen; // ww.Height = 400; // ww.ShowDialog(); // string code = ww.Codigo; // reflector.SetValue(rowData, "cod_ref", code); // GridConfig.UpdateDataRow(columnIndex); // GridConfig.UpdateLayout(); // GridConfig.Columns["cod_ref"].AllowEditing = true; // } // else // { // string refe = reflector.GetValue(rowData, "cod_ref").ToString().Trim(); // if (string.IsNullOrEmpty(refe)) // { // dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia"); //carga desde sql // ww.Conexion = SiaWin.Func.DatosEmp(idemp); // ww.idEmp = idemp; // ww.idBod = tx_bodega.Text; // ww.UltBusqueda = ""; // ww.ShowInTaskbar = false; // ww.Owner = Application.Current.MainWindow; // ww.WindowStartupLocation = WindowStartupLocation.CenterScreen; // ww.Height = 400; // ww.ShowDialog(); // string code = ww.Codigo; // reflector.SetValue(rowData, "cod_ref", code); // GridConfig.UpdateDataRow(columnIndex); // GridConfig.UpdateLayout(); // GridConfig.Columns["cod_ref"].AllowEditing = true; // } // } } catch (Exception w) { SiaWin.Func.SiaExeptionGobal(w); MessageBox.Show("error Activiting:" + w); } }
private void DataProducto_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) { try { if ((Keyboard.IsKeyDown(Key.F8)) || (Keyboard.IsKeyDown(Key.F6))) { int idr = 0; string code = ""; string nom = ""; dynamic winb = SiaWin.WindowBuscar("inmae_ref", "cod_ref", "nom_ref", "cod_ref", "idrow", "Maestra dereferencia", SiaWin.Func.DatosEmp(idemp), false, "", idEmp: idemp); winb.ShowInTaskbar = false; winb.Owner = Application.Current.MainWindow; winb.Height = 300; winb.Width = 400; winb.ShowDialog(); idr = winb.IdRowReturn; code = winb.Codigo; nom = winb.Nombre; winb = null; //Productos productos = new Productos(Convert.ToString(code), Convert.ToString(nom), "", "", "", ""); //_productos.Add(new Productos(Convert.ToString(code), Convert.ToString(nom),"","","","")); //var uiElement = e.OriginalSource as UIElement; //uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down)); //Productos row = (DataRowView)DataProducto.SelectedItems[0]; //row["cod_ref"] = code; //Productos pr = new Productos(code, code, code, code, code, code); //pr.Referencia = "ejmeplo"; //DataProducto.UpdateDataRow(e.RowColumnIndex.RowIndex); //if (idr > 0) //{ // TB_CodigoZonaSuc.Text = code; // TB_ZonaSuc.Text = nom; // var uiElement = e.OriginalSource as UIElement; // uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down)); //} } else { MessageBox.Show("no llego"); } } catch (Exception w) { MessageBox.Show("error!!:" + w); } }
/// <summary> /// Raises the <see cref="Syncfusion.UI.Xaml.Grid.SfDataGrid.CurrentCellValidating"/> event. /// </summary> /// <param name="dataGrid"> /// Specifies the corresponding grid . /// </param> /// <param name="column"> /// The corresponding column that was in edit mode. /// </param> /// <param name="oldValue"> /// The cell value before edited. /// </param> /// <param name="newValue"> /// The value of the current cell is being edited. /// </param> /// <param name="changedNewValue"> /// The cell value after editing completed. /// </param> /// <returns> /// <b>true</b> if <see cref="Syncfusion.UI.Xaml.Grid.SfDataGrid.CurrentCellValidating"/> event is raised; otherwise, <b>false</b>. /// </returns> public bool RaiseCurrentCellValidatingEvent(SfDataGrid dataGrid, GridColumn column, object oldValue, object newValue, out object changedNewValue) { var e = new CurrentCellValidatingEventArgs(dataGrid) { OldValue = oldValue, NewValue = newValue, Column = column }; bool isSuspendValidating = DataGrid.RaiseCurrentCellValidatingEvent(e); changedNewValue = e.NewValue; return(isSuspendValidating); }
private void ChangeProperty(GridTreeNode ParentNod, string value, CurrentCellValidatingEventArgs e) { foreach (GridTreeNode nod in ParentNod.ChildNodes) { object mnu = nod.Item; mnu.GetType().GetProperty(ComboProperty).SetValue(mnu, value); this.AssociatedObject.InternalGrid.InvalidateCell(e.Style.CellRowColumnIndex); if (nod.HasChildNodes == true) { ChangeProperty(nod, value, e); } } }
void AssociatedObject_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) { if ((e.Style.CellRowColumnIndex.ColumnIndex == 2 && e.Style.CellRowColumnIndex.RowIndex == 6) || (e.Style.CellRowColumnIndex.ColumnIndex == 2 && e.Style.CellRowColumnIndex.RowIndex == 8)) { if (e.Style.HasIntegerEdit) { e.Cancel = OnValidateIntegerEdit(e); } else if (e.Style.HasDoubleEdit) { e.Cancel = OnValidateDoubleEdit(e); } e.Handled = true; } }
private void Datagrid_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args) { if (args.Column.MappingName != "salary") { return; } double d; if (args.NewValue == null || !double.TryParse(args.NewValue.ToString(), out d)) { args.ErrorMessage = "Enter valid double value"; args.IsValid = false; } }
/// <summary> /// Handles the CurrentCellValidating event of the grid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Syncfusion.Windows.Controls.Grid.CurrentCellValidatingEventArgs"/> instance containing the event data.</param> void OnCurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) { if (!IsCellValidating) return; int colidx = this.AssociatedObject.Model.ResolvePositionToVisibleColumnIndex(e.Style.ColumnIndex); string column = this.Grid.VisibleColumns[colidx].MappingName; Products product = null; if (this.AssociatedObject.GroupedColumns.Count > 0) { var record = Grid.Model.Table.GetRecordFromRow(e.Style.RowIndex) as GridDataRecord; if (record != null) product = (Products)record.Data; } else product = (Products)Grid.Model.Table.GetRecordFromRow(e.Style.RowIndex); e.Cancel = Validate(column, e.NewValue, e.Style, product); }
void AssociatedObject_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) { if (e.Style.HasIntegerEdit) { if (!OnValidateIntegerEdit(e)) { ShowDataValidationMsg(e); } } if (e.Style.HasDoubleEdit) { if (!OnValidateDoubleEdit(e)) { ShowDataValidationMsg(e); } } }
protected override void Invoke(object parameter) { if (parameter is RowValidatingEventArgs) { RowValidatingEventArgs args = parameter as RowValidatingEventArgs; var data = args.RowData as OrderInfo; decimal columnData = 0; decimal compareData = 0; double total = data.Freight + data.Expense; decimal.TryParse(total.ToString(), out columnData); decimal.TryParse("3000", out compareData); NumberFormatInfo numberFormatInfo = new NumberFormatInfo() { CurrencyDecimalDigits = NumberFormatInfo.CurrentInfo.CurrencyDecimalDigits, CurrencyDecimalSeparator = NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator, CurrencyGroupSeparator = NumberFormatInfo.CurrentInfo.CurrencyGroupSeparator, CurrencyNegativePattern = NumberFormatInfo.CurrentInfo.CurrencyNegativePattern, CurrencyPositivePattern = NumberFormatInfo.CurrentInfo.CurrencyPositivePattern, CurrencySymbol = NumberFormatInfo.CurrentInfo.CurrencySymbol, }; if (Convert.ToDouble(columnData) < Convert.ToDouble(compareData)) { args.ErrorMessages.Add("Expense", "Sum of Expense and Freight should be a minimum of 3000 to be eligible for Discount."); args.IsValid = false; } } else { CurrentCellValidatingEventArgs args = parameter as CurrentCellValidatingEventArgs; if (args.Column.MappingName == "Discount" && Convert.ToDouble(args.NewValue) > 40) { args.ErrorMessage = "Discount should not exceed 40 percent."; args.IsValid = false; } } }
void cellgrid_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args) { eventsTxtBox.Text += "\nCurrent cell validating"; }
void AssociatedObject_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args) { }