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.

Reg:GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

46667 Jul 18,2006 08:13 AM Jul 20,2006 09:22 AM Windows Forms 5
loading
Tags: GridControl
Anna Srinivasan
Asked On July 18, 2006 08:13 AM

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 08:29 AM

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 03:58 AM

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

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

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

Anna Srinivasan
Replied On July 20, 2006 06:43 AM

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

Administrator [Syncfusion]
Replied On July 20, 2006 09:22 AM

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

CONFIRMATION

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.

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.

;