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
close icon

Reg:GridControl

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

5 Replies

AD Administrator Syncfusion Team 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


AS Anna Srinivasan July 19, 2006 07:58 AM UTC

Hi,
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…..

Thanks,
Anna


AD Administrator Syncfusion Team 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,
Haneef


AS Anna Srinivasan 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...

Thanks,
Anna


AD Administrator Syncfusion Team 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.

Thanks
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon