[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.
Post Reply
klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

[solved ]Display Value on GUI

Post by klarlichter » Thu Nov 21, 2019 5:01 pm

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 6:13 pm, edited 1 time in total.

jvierra
Posts: 14016
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Display Value on GUI

Post by jvierra » Thu Nov 21, 2019 5:41 pm

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
Joined: Tue Nov 19, 2019 1:17 am

Re: Display Value on GUI

Post by klarlichter » Thu Nov 21, 2019 5:49 pm

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

Re: Display Value on GUI

Post by jvierra » Thu Nov 21, 2019 6:04 pm

$label1.Text = 'my text'

klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

Re: Display Value on GUI

Post by klarlichter » Thu Nov 21, 2019 6:07 pm

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
Joined: Tue Nov 19, 2019 1:17 am

Re: Display Value on GUI

Post by klarlichter » Thu Nov 21, 2019 6:12 pm

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

Re: [solved ]Display Value on GUI

Post by jvierra » Thu Nov 21, 2019 6:19 pm

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

Re: [solved ]Display Value on GUI

Post by jvierra » Thu Nov 21, 2019 6:32 pm

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.

Post Reply