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

Restrict the length of a pasted string

Hi, I have searched the forums but cant find the solution to what seems like a very silly problem; The user is only allowed to enter max 30 chars in a grid cell. I can handle the typing of chars in the CurrentCellKeyPress event, but when the user paste into the cell my length restriction gets bypassed. How do i interrupt the paste process so only the first 30 chars end up in the cell? regards Fredrik

4 Replies

ST stanleyj Syncfusion Team January 18, 2006 12:16 PM UTC

Hi Fredrik, Try handling PasteCellText to strip off the extra characters. private void gridControl1_PasteCellText(object sender, GridPasteCellTextEventArgs e) { string s = e.Text; e.Text = s.Remove(30,(s.Length-30)); } Best regards, Stanley


FS Fredrik Ström January 18, 2006 01:16 PM UTC

Thanx for the answer Stanley, but the I don''t seem to get the PasteCellText event. I do get the ClipboardPaste though. regards Fredrik


FS Fredrik Ström January 18, 2006 01:17 PM UTC

Thanx for the answer Stanley, but the I don''t seem to get the PasteCellText event. I do get the ClipboardPaste though. regards Fredrik


FS Fredrik Ström January 18, 2006 01:17 PM UTC

Thanx for the answer Stanley, but the I don''t seem to get the PasteCellText event. I do get the ClipboardPaste though. regards Fredrik

Loader.
Live Chat Icon For mobile
Up arrow icon