Help with a "Select All and Copy to Clipboard" button? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Help with a "Select All and Copy to Clipboard" button?

Last post 02-18-2016 11:16 AM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-17-2016 02:26 PM

    Help with a "Select All and Copy to Clipboard" button?

    I am EXTREMELY new to infopath and I only know how to do extremely basic stuff. I am needing help setting it up to where anything that is in a text box at the bottom a form I am creating can be all be selected and copied to the clipboard with the click of a button. I have no clue where to even begin and I know nothing about coding, period. I have a beginners understanding of Rules and how to manage them, if that helps. But yeah, I am making a form that as you fill out required fields, it auto-populates a text field at the end to say what needs to be said in a notes section for something at my job. So i want the button to take everything that has been autopopulated into the field and copy it to the clipboard. Can someone help me with a "for-dummies", step-by-step guide as to how to make this button in infopath designer? It does not need to work on the web or anything, it is for offline use.
  • 02-18-2016 07:48 AM In reply to

    Re: Help with a "Select All and Copy to Clipboard" button?

    With a filler form, set to use C#, that has a using System.Windows.Forms statement at the top of the code file, add code to your button:

    string text = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1", NamespaceManager).Value;

    Clipboard.SetText(text);

    See the part in bold that says "/my:myFields/myfield1"?

    You need to change that to the correct XPath for your field. Find the field in the fields task pane in InfoPath designer. Right click and select Copy XPath, then paste it in.

     

    Hilary Stoupa

  • 02-18-2016 09:15 AM In reply to

    Re: Help with a "Select All and Copy to Clipboard" button?

    This is giving me some weird error. As I said I am exteremely noobie to this, so bare with me. But yeah, i copied the xpath of the note output and pasted it in the code you gave me, then copied the entire code, right clicked on my button, hit "button properties" then hit the "fx" symbol to put the code in and pasted it in there and got an error saying jibberish. Any advise? :/
  • 02-18-2016 11:16 AM In reply to

    Re: Help with a "Select All and Copy to Clipboard" button?

    You need to add code to the form. You cannot do what you want with just rules in InfoPath - right click your button and select the button properties, then you can add code to the button.
    Hilary Stoupa

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.