We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Column type

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

1 Reply

AD Administrator Syncfusion Team August 24, 2004 02:29 AM

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).

Loader.
Live Chat Icon For mobile
Up arrow icon