MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

Disable Copy/Paste on a datawindow

Published on 21 September 18
448
0
0

Some times uses will be copy/pasting on datawindow due to which issues may happen (specially in the trademark symbols etc.,)

So we may need to restrict copy pasting on datawindow/ only some columns on datawindow.

The below code will be usefull to acheive this.

In this case I have used demo database to create a freeform datawindow and I am not allowing copy/paste on 2 columns. Also I am showing a message box to users that copy pasting is not allowed on those 2 columns.

No need to think Item changed/ Clicked, In this case we will be using a windows event ID to acheive this

Before we proceed make sure that Ctrl + V is not used in the menu. In this case the menu Ctrl+V will supress our event.

In the datawindow on which you need to restrict copy/Paste, create a event and map to pbm_dwnkey and external check box unchecked. Write the below code in that-

boolean ib_CaptureTab = true string ls_columnname ls_columnname =this.getcolumnname() IF trim(ls_Columnname) <> "" THEN // 86 Is the ANSCII value for V IF ib_CaptureTab AND KeyDown(Keycontrol!) and KeyDown(86) and (ls_columnname ='first_name' or ls_columnname='city') THEN string ls_1 = '' ls_1 = clipboard() ls_1 ="" ::clipboard(ls_1) MessageBOx("Info","You can't use copy/paste on this field.Please type manually") END IF END IF

In above code I have restricted cntrl+v on firstname and city. You need to modify your code accordingly.

Also some cases if users know that Shift +Insert also works to copy then we need to modify code for that also.

Just add onemore if condition for KeyDown(KeyShift!) and KeyDown(KeyInsert!). Thats it.

Hope you enjoy the above technique!! :) :)

Disable Copy/Paste on a datawindow - Image 1

Some times uses will be copy/pasting on datawindow due to which issues may happen (specially in the trademark symbols etc.,)

So we may need to restrict copy pasting on datawindow/ only some columns on datawindow.

The below code will be usefull to acheive this.

In this case I have used demo database to create a freeform datawindow and I am not allowing copy/paste on 2 columns. Also I am showing a message box to users that copy pasting is not allowed on those 2 columns.

No need to think Item changed/ Clicked, In this case we will be using a windows event ID to acheive this

Before we proceed make sure that Ctrl + V is not used in the menu. In this case the menu Ctrl+V will supress our event.

In the datawindow on which you need to restrict copy/Paste, create a event and map to pbm_dwnkey and external check box unchecked. Write the below code in that-

boolean ib_CaptureTab = true string ls_columnname ls_columnname =this.getcolumnname() IF trim(ls_Columnname) "" THEN // 86 Is the ANSCII value for V IF ib_CaptureTab AND KeyDown(Keycontrol!) and KeyDown(86) and (ls_columnname ='first_name' or ls_columnname='city') THEN string ls_1 = '' ls_1 = clipboard() ls_1 ="" ::clipboard(ls_1) MessageBOx("Info","You can't use copy/paste on this field.Please type manually") END IF END IF In above code I have restricted cntrl+v on firstname and city. You need to modify your code accordingly.

Also some cases if users know that Shift +Insert also works to copy then we need to modify code for that also.

Just add onemore if condition for KeyDown(KeyShift!) and KeyDown(KeyInsert!). Thats it.

Hope you enjoy the above technique!! :) :)

Disable Copy/Paste on a datawindow - Image 1

This blog is listed under Development & Implementations Community

Related Posts:
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top