[solved ]Display Value on GUI

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 4 years and 4 months 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
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

[solved ]Display Value on GUI

Post by klarlichter »

Hello,
if it is possible to display a value / variable on gui?

I try to place a label and teh setup on code the variable who should display. It is only working after cklick on label.... how it could be display direct an not only after click on label?
Last edited by klarlichter on Thu Nov 21, 2019 5:13 pm, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Display Value on GUI

Post by jvierra »

Values display when they are assigned. I recommend that you take some time to learn PowerShell before trying to work with forms. Without good basic PowerShell knowledge you wil not be able to work with forms.

Also you can look here for help with controls: https://info.sapien.com/index.php/guis/ ... el-control
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: Display Value on GUI

Post by klarlichter »

Hi. Bitty step by step. I read that page before. That’s why I ask. I place the label. But I not want show default level text. I want show some variable like $output = „my text“ but that working only after klick ob label1. I would like override label1 while that form start to display. :(
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Display Value on GUI

Post by jvierra »

$label1.Text = 'my text'
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: Display Value on GUI

Post by klarlichter »

That I try but it change ‚my text‘ only after I click on label1... it not display while the form are open.
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: Display Value on GUI

Post by klarlichter »

Ok,
I find. That Command $label1.Text = 'my Text' need placed on

Code: Select all

$MainForm_Load={
	#TODO: Initialize Form Controls here
	$label1.Text = 'my Text'
}
Then it will be worked. Thanks a lot. :)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [solved ]Display Value on GUI

Post by jvierra »

Where were you putting it? In a click event? You can add default text in the designer and it will be incorporated into the code correctly.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [solved ]Display Value on GUI

Post by jvierra »

Here is a good free book on PowerShell. It has a chapter on designing and building with WinForms.

https://www.sapien.com/books_training/W ... werShell-4
See Chapter 21.
This topic is 4 years and 4 months 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