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

copy paste textbox maxlength question?

Thread ID:





29368 May 24,2005 02:06 PM UTC May 25,2005 06:51 PM UTC WinForms 9
Tags: GridControl
Philip Bishop
Asked On May 24, 2005 02:06 PM UTC

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?

Administrator [Syncfusion]
Replied On 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.

Philip Bishop
Replied On 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?

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On May 25, 2005 01:01 PM UTC

Just emailed you a sample.

Administrator [Syncfusion]
Replied On May 25, 2005 01:01 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On May 25, 2005 06:51 PM UTC

Thanks Clay. Thats exactly what i wanted.


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