Hello Infopathdev! I have quite an interesting issue to share with you folks today. I'll start off by stating VB is not my strongpoint. But because the builder in infopath can literally teach you how to write VB i've gotten a pretty good grasp of the syntaxs and what not.
I'll start off by explaining how I have my form laid out. I do not have this form set up for used to "submit" it in the traditional sense. Users fill out the fields in the form, once complete they press a button at the bottom of the form and it uses a formula to populate a text box with the information provided in the fields. That way they can just fill out the fields, click the button, and copy/paste from the textbox to notepad.
I ran into some troubles yesterday with the button. It would post all of the fields properly, but the text box would not do line breaks as the button at "set the fields value" was a function. To do this I had to create and XML file and add it as a secondary source so that I could use @crlf fields in my function to red-neck a line break in the text box, which mind you, outside of a little extra legwork on building the functions, works fine. The field would correctly populate like this:
Butter
Eggs
Milk
Bread
However, today I decided to create another button. This button, through some vb form coding, should allow me to copy the field to clipboard by simply clicking it. The code is as follows:
Dim nodeToCopy As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field10", NamespaceManager)
If Not String.IsNullOrEmpty(nodeToCopy.Value) Then
Clipboard.SetText(nodeToCopy.Value, TextDataFormat.CommaSeparatedValue)
Else
MessageBox.Show(
"There is no text to copy")
Now heres the issue, after building it and saving my form, it will correctly copy the field to clipboard almost like it should, heres my problem. When I go to paste this info, it loses its linebreaks like
ButterEggsMilkBread
Iv'e tried many different text formats at "TextDataFormat.CommaSeparatedValue) and nothing seems to work.
I'm open to any advice