public class DataGridNumericColumn : DataGridTextColumn { protected override object PrepareCellForEdit(System.Windows.FrameworkElement editingElement, System.Windows.RoutedEventArgs editingEventArgs) { TextBox edit = editingElement as TextBox; edit.PreviewTextInput += OnPreviewTextInput; return base.PrepareCellForEdit(editingElement, editingEventArgs); } void OnPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) { try { Convert.ToInt32(e.Text); } catch { e.Handled = true; } } } private Collection field = new Collection(); [Category("Data")] [Description("Column Creation")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Collection Columns { get { return field; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)