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.
jvierra
Posts: 14213
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: XML data to a label.text property

Post by jvierra »

Please post the code that sets that variable? This variable ->>> $detailsLBL

User avatar
miketartaglia
Posts: 97
Joined: Mon Feb 02, 2015 7:44 am

Re: XML data to a label.text property

Post by miketartaglia »

jvierra wrote:
Thu Feb 21, 2019 11: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: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: XML data to a label.text property

Post by jvierra »

Sorry I meant to ask for this variable $BindingURL.

User avatar
miketartaglia
Posts: 97
Joined: Mon Feb 02, 2015 7:44 am

Re: XML data to a label.text property

Post by miketartaglia »

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: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

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 29 times

User avatar
miketartaglia
Posts: 97
Joined: Mon Feb 02, 2015 7:44 am

Re: XML data to a label.text property

Post by miketartaglia »

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.

Locked