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.

copy paste textbox maxlength question?

Thread ID:

Created:

Updated:

Platform:

Replies:

29368 May 24,2005 10:06 AM May 25,2005 02:51 PM Windows Forms 9
loading
Tags: GridControl
Philip Bishop
Asked On May 24, 2005 10:06 AM

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 11: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.

Philip Bishop
Replied On May 24, 2005 11: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?

Administrator [Syncfusion]
Replied On May 24, 2005 11: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.

Administrator [Syncfusion]
Replied On May 24, 2005 12:28 PM

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 08: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.

Administrator [Syncfusion]
Replied On May 25, 2005 09:01 AM

Just emailed you a sample.

Administrator [Syncfusion]
Replied On May 25, 2005 09:01 AM

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

Administrator [Syncfusion]
Replied On May 25, 2005 11: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

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

Thanks Clay. Thats exactly what i wanted.

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.

;