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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set MaxLength to the GridColumns?

You can define MaxLength to the GridColumn in display mode by using DisplayBinding and IValueConverter interface as follows.





Note: You can use Converter in Value Binding also as follows.



You can also restrict the MaxLength in edit mode by writing Style to TextBox since MS TextBox will be loaded while editing GridTextColumn.


Please refer the below code snippet.




The MaxLength can be set for a particular column by deriving a new class from GridCellTextBoxRenderer and override the OnInitializeEditElement method with the help of TextBox.MaxLength property as follows.




Sample Links:




Article ID: Published Date: Last Revised Date: Platform: Control:
5508 10/26/2015 01/20/2016 WPF SfDataGrid
Did you find this information helpful?
Ömer Faruk Mar 29, 2018


How can set maxlenght to the gridcolumns in winforms ?

there is no an example about this issue...

Ömer Faruk Mar 29, 2018

I found a solution like this;

 private void sfDataGrid1_CurrentCellValidating(object sender, Syncfusion.WinForms.DataGrid.Events.CurrentCellValidatingEventArgs e)



            if (e.NewValue.ToString().Length>20)


                e.IsValid = false;

                e.ErrorMessage = "Cannot maximum lenght more then 20";



Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon