title: How to import data from TXT or XML file into Powershell textbox or listbox
body: <p>I'm looking for a way to import a TXT or XML (preferred) file into powershell and then show the information in a large textbox or listbox (I've been trying both). The reason I'd prefer XML is that there are 3 sections and I don't want 3 different files. This is for a GUI script that has a "help" button which pops up a smaller GUI window. The help window has 3 buttons, How To Use, Error Msgs, and Update Notes. I'd like the XML file to look like this...</p>
  
  <pre><code>&lt;Help&gt;
  &lt;HowTo&gt;
      Text line 1
      Text line 2
      Text line 3
  &lt;/HowTo&gt;
  &lt;Errors&gt;
      More text
  &lt;/Errors&gt;
  &lt;Updates&gt;
      More text
  &lt;/Updates&gt;
  &lt;/Help&gt;
  </code></pre>
  
  <p>Each button would show the appropriate XML text in a large textbox. I can get it to show the text from the XML just fine, however I can't figure out how to have it display correctly on new lines like I have it typed in the XML file itself. In the example above I'd click the "How To Use" button and it'd show the 3 lines like it does above. If it tried that now it would show like...</p>
  
  <pre><code>Text line1Text line 2Text line 3
  </code></pre>
  
  <p>I'm currently trying to make it work with a textbox that has multiline enabled so it does wrap around when it gets too long, but there are no proper line breaks. I've tried formatting the XML lines to force a line break, but it didn't work.</p>
  
  <pre><code>Text line 1 `r`n
  Text line 2 `r`n
  etc.
  </code></pre>
  
  <p>I'm currently using Get-Content to save the TXT or XML file into a variable. If there's another way to allow it to keep it's formatting that would be helpful. I haven't been able to find anything.</p>
  
  <hr>
  
  <p>UPDATE: Trying labels</p>
  
  <p>Using labels keeps the correct formatting, and it re-sizes the window correctly, however when the window re-sizes the buttons stay where they're at. Here's a screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/zmFQI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zmFQI.jpg" alt=""></a></p>
  
  <p>Is there a way for the buttons to follow the box when it's resized, and is there any vertical scroll option? Each button will have a good amount of text so it'll  probably need to scroll.</p>