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

How to set MaxLength to the GridColumns?

Platform: WPF |
Control: SfDataGrid

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:




2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment
Ö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";



Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile