【问题标题】:input only numbers in the datatable WPF在数据表 WPF 中仅输入数字
【发布时间】:2015-10-05 12:08:39
【问题描述】:

我有一个Datatable,如何制作,所以用户只能在Datatable的行中输入数字?

DataColumn column;
            DataRow row;

            column = new DataColumn();
            column.DataType = System.Type.GetType("System.String");
            column.ColumnName = "Типы";
            column.ReadOnly = true;

【问题讨论】:

  • 与您要查找的内容相同,但带有一个文本框:stackoverflow.com/a/463335/5147720
  • 你在使用 DataGrid 吗?将 DataGridTemplateColumn 与 CellTemplate 中的 TextBox 一起使用。然后,您可以收听 PreviewKeyPress 事件以拒绝字母按键。
  • cscmh99 谢谢你,我做到了

标签: c# wpf datatable


【解决方案1】:
 DataTable myTable = new DataTable();
 myTable.Columns.Add("numericColumn", typeof(Int32)); // for integer column
 myTable.Columns.Add("CharColumn", typeof(char)); // for character column
 myTable.Columns.Add("DecimalColumn", typeof(Decimal)); // for Decimal column

【讨论】:

  • 谢谢解答,但是按照数字,还是可以输入字符的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-05
  • 2010-12-19
  • 1970-01-01
  • 2020-03-26
  • 2017-03-22
相关资源
最近更新 更多