The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi
Wiil this statement allows only integers in the cells of the column MyColumn
datatable.Columns.Add(new DataColumn("MyColumn", typeof(int)));
how to make cells accept only integers, decimals, strings etc
---seash
ADAdministrator Syncfusion Team August 24, 2004 06:29 AM UTC
I assume you are trying to bind your datatable to a GridDataBoundGrid.
If you do not explicitly add GridBoundColumns that change something, using that declaration to create a DataColumn should make the grid catch an exception, and display an error message if your user tried to type something that was not a valid integer. When you tried it, did it not work for you?
Another place you can set the system.Type for a column is the GridBoundColumn.StyleInfo.CellValueType for the particular column. If you explicitly add the GridBoundColumns, then you access these columns through the grid.GridBoundColumns collection. If you have not explicitly added GridBoundColumns, then you use grid.Binder.InternalColumns to get at the GridBoundColumn for a particular column.
Now the default support lets you user type anything, and then catches the exception as the user tries to leave the cell. If you want to validate the cell keystroke by keystroke (ie ignore keys that are invalid like letters in a integer), then you will have to handle the CurrentCellValidateString event, and validate teh e.Text that is passed in, setting e.Cancel = true if it is invalid. (You can get the row/col by getting the grid.CurrentCell.RowIndex/COlIndex).