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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





46667 Jul 18,2006 12:13 PM UTC Jul 20,2006 01:22 PM UTC WinForms 5
Tags: GridControl
Anna Srinivasan
Asked On July 18, 2006 12:13 PM UTC

Hi, I am having combobox on my grid control. I want to restrict the user to enter more than 10 character on the cell. So I used maxlength property but i was not working. Kindly help me on this. Example code: this.sfgLastBrokerPrice.Model.ColWidths[(int)lastBrokerPriceCols.SpeedType] = 70; this.sfgLastBrokerPrice[0, (int)lastBrokerPriceCols.SpeedType].Text = "Speed Type"; this.sfgLastBrokerPrice[1, (int)lastBrokerPriceCols.SpeedType].CellType = cboCellType; this.sfgLastBrokerPrice[1, (int)lastBrokerPriceCols.SpeedType].DataSource = speedTypeView; this.sfgLastBrokerPrice[1, (int)lastBrokerPriceCols.SpeedType].ValueMember ="LOOKUP_ID"; this.sfgLastBrokerPrice[1, (int)lastBrokerPriceCols.SpeedType].DisplayMember ="LOOKUP_VALUE"; this.sfgLastBrokerPrice[1, (int)lastBrokerPriceCols.SpeedType].MaxLength = 10; //DB datatype max length Thanks, Anna

Administrator [Syncfusion]
Replied On July 18, 2006 12:29 PM UTC

Hi Anna, Could you try this code snippet in Grid''s CurrentCell KeyPress event to resolve this issue. Here is a code snippet. GridComboBoxCellRenderer cr = this.gridControl1.CurrentCell.Renderer as GridComboBoxCellRenderer; if (cr != null && cr.ControlText != string.Empty && cr.ControlText != null ) { if( cr.ControlText.Length > 10 ) e.Handled = true; } Let me know if this helps. Best Regards, Haneef

Anna Srinivasan
Replied On July 19, 2006 07:58 AM UTC

I know that we can achieve this functionality using key press event, But I want to know that why the max length property is not working on combobox. If it is a syncfusion bug, when will this problem get resolved.
Kindly help me…..


Administrator [Syncfusion]
Replied On July 19, 2006 08:53 AM UTC

Hi Anna,

Thanks for your update.

The GridStyleInfo.MaxLength properly is only used with the TextBox cell type. For other cell types, you would have to handle things yourself.

A straight-forward way of doing this is to handle the CurrentCellKeyPress event and set e.Handled if the current string is to long.

Let me know if i am missing something.
Best Regards,

Anna Srinivasan
Replied On July 20, 2006 10:43 AM UTC

Hi Haneef,
Thanks for your update.
I agree, If the user enters value through keyboard, we can handle through keypress event. Let say user is doing Ctrl+C(Copy) and Ctrl+V(Past). How we can restrict the maxlength on the combo cell.

Please help me on this...


Administrator [Syncfusion]
Replied On July 20, 2006 01:22 PM UTC

Hi Anna,

You can use the grid.Model.PasteCellText event to do cell by cell validation as you paste into a Grid.

Let us know if this is not what you needed.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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