0

I have a Datatable, how to make, so the user can enter only numbers in rows Datatable?

DataColumn column;
            DataRow row;

            column = new DataColumn();
            column.DataType = System.Type.GetType("System.String");
            column.ColumnName = "Типы";
            column.ReadOnly = true;
  • 1
    The same thing that you are looking for, but with a textbox: http://stackoverflow.com/a/463335/5147720 – Jose Oct 05 '15 at 12:22
  • Are u using DataGrid ? Use DataGridTemplateColumn with a TextBox in CellTemplate. You can then listen to PreviewKeyPress event to reject alphabet keypress. – cscmh99 Oct 05 '15 at 15:59
  • cscmh99 Thanks, you so i did –  Oct 06 '15 at 05:44

1 Answers1

0
 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
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
  • Thanks for the answer, but in line with the numbers, you can still enter characters –  Oct 05 '15 at 12:39