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

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 03:40 PM UTC

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 03:51 PM UTC

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 03:57 PM UTC

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 04:28 PM UTC

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 12:54 PM UTC

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 01:01 PM UTC

Just emailed you a sample.


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

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


AD Administrator Syncfusion Team May 25, 2005 03:00 PM UTC

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 06:51 PM UTC

Thanks Clay. Thats exactly what i wanted.

Loader.
Live Chat Icon For mobile
Up arrow icon