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

copy paste textbox maxlength question?

Im having a problem copying and pasting text that just showed up today. We have some grids that have the maxlength property set for example to 8. So the user can only enter up to 8 characters. The problem is this. Go to excel or notepad and type in 50 a''s then swipe them all. If you then copy and paste them in to my textbox cell that can only hold 8 it will paste all 50 a''s. How do you prevent copying more then the maxlength entry will permit?

9 Replies

AD Administrator Syncfusion Team May 24, 2005 10:40 AM

Philip, From Syncfusion documentation: GridStyleInfo.MaxLength Property Limits the number of characters the user can type into the cell. Note: When selecting a text from a choice list or when pasting text, the text can be longer. Additional validation is necessary on your side.


PB Philip Bishop May 24, 2005 10:51 AM

Ok so you mean i have to do this like when i close a form and then check all the text fields and see if they are longer then 8?


AD Administrator Syncfusion Team May 24, 2005 10:57 AM

Well, I am no grid expert, but you might want to handle the CellsChanged event and truncate the string if it is longer than the max length.


AD Administrator Syncfusion Team May 24, 2005 11:28 AM

You will have to handle the PasteCellText event and set e.Cancel = true if you do not want to paste the value for whatever reason, eg. it is too long.


AD Administrator Syncfusion Team May 25, 2005 07:54 AM

Clay, I thought thats what I should do also. When i tried it however i found that it doesnt go to the paste cell text event. Im copying from word and pasting in to a textbox cell. So I am copying to just ONE cell. I know in the past I''ve found in testing and talking to you that some events dont happen on a one to one copy. I can send a sample if you dont see the same behavior.


AD Administrator Syncfusion Team May 25, 2005 08:01 AM

Just emailed you a sample.


AD Administrator Syncfusion Team May 25, 2005 08:01 AM

Cell 1,1 is one you can try to paste in to.


AD Administrator Syncfusion Team May 25, 2005 10:00 AM

Thank you for you sample. You can get the PasteCellText hit in this case by handling the ClipboardPaste event and setting teh IgnoreCurrentCell to be true as this paste is handled like a multi-cell paste. Private Sub grdDateRange_ClipboardPaste(ByVal sender As Object, ByVal e As GridCutPasteEventArgs) Handles grdDateRange.ClipboardPaste e.IgnoreCurrentCell = True End Sub


AD Administrator Syncfusion Team May 25, 2005 01:51 PM

Thanks Clay. Thats exactly what i wanted.

Loader.
Live Chat Icon For mobile
Up arrow icon