XML data to a label.text property

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

This is the variable you need to check: $BindingURL'

Code: Select all

$buttonSEARCH_Click= {
     [System.Windows.Forms.MessageBox]::Show($BindingURL')  # <==== get the value of the variable
     [xml]$file = (Get-Content 'c:\test\programdata\Server Configuration.xml')
     $detailsLBL.Text = $file.SelectSingleNode("//Instance[BindingHostName='$BindingURL']").Name
 } 
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

Please post the code that sets that variable? This variable ->>> $detailsLBL
User avatar
mtartaglia
Posts: 101
Last visit: Mon Dec 19, 2022 11:45 am

Re: XML data to a label.text property

Post by mtartaglia »

jvierra wrote: Thu Feb 21, 2019 10:09 am Please post the code that sets that variable? This variable ->>> $detailsLBL
$buttonSEARCH_Click= {
#TODO: Place custom script here
[xml]$file = (Get-Content 'c:\test\programdata\Server Configuration.xml')
$detailsLBL.Text = ($file.SelectSingleNode("//Instance[BindingHostName='$BindingURL']").Name)

}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

Sorry I meant to ask for this variable $BindingURL.
User avatar
mtartaglia
Posts: 101
Last visit: Mon Dec 19, 2022 11:45 am

Re: XML data to a label.text property

Post by mtartaglia »

I don't know where that code is. What you are talking about is a text box Named BindingURL. I enter text in this box and I assumed that the variable is set then. Please correct me if I'm wrong.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

How can you not know where the code is? You wrote it didn't you.

It sounds to me like the variable is not a simple text variable. If it is the text box then it is an object. I posted twice telling you how to determine what you have. Please go back and address the posts you ignored. They outline how to determine the issue and how to fix it.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

Sorry for the short answer butI am in the middle of something.

A textbox has a property that gets the contents.

For instructions on how to use a textbox control see: https://info.sapien.com/index.php/guis/ ... ox-control
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: XML data to a label.text property

Post by jvierra »

I had a couple of minutes to kill so here is an example form showing how to use my XML code to query from a textbox and update a control. It is very simple.
Attachments
Test-XPathResults.psf
(35.97 KiB) Downloaded 110 times
User avatar
mtartaglia
Posts: 101
Last visit: Mon Dec 19, 2022 11:45 am

Re: XML data to a label.text property

Post by mtartaglia »

That made me see the light. The problem was with me not assigning the $BindingURL.text to a variable after the user clicked the search button. Now I remember how to do it. thanks for the guidance.
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked