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.

Restrict the length of a pasted string

Thread ID:

Created:

Updated:

Platform:

Replies:

39782 Jan 18,2006 05:01 AM Jan 18,2006 08:17 AM Windows Forms 4
loading
Tags: GridControl
Fredrik Ström
Asked On January 18, 2006 05:01 AM

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

stanleyj [Syncfusion]
Replied On January 18, 2006 07:16 AM

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

Fredrik Ström
Replied On January 18, 2006 08:16 AM

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

Fredrik Ström
Replied On January 18, 2006 08:17 AM

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

Fredrik Ström
Replied On January 18, 2006 08:17 AM

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

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.

;