textbox

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 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
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

textbox

Post by mqh77777 »

On a powershell studio form we use text boxes so users can enter data. Is there a way to show shadow text in the text box saying what to enter? Example if the Textbox was for "computer name" to display enter computer name in the textbox so they know what to enter?
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: textbox

Post by mxtrinidad »

In the Textbox control, use the Text property to enter a text to be display when it initially open the forms.
Other than that, you could add code to keep displaying the text after it get's process.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: textbox

Post by davidc »

You can use the TextBox - Watermark control set:

https://www.sapien.com/blog/2013/08/14/new-control-set-textbox-watermark/
David
SAPIEN Technologies, Inc.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: textbox

Post by mqh77777 »

Thanks, I read that webpage. I'm unclear on where you place all of this code. Is it on the properties of the textbox? Or under "form load"? Or both?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: textbox

Post by jvierra »

What code. Just add the watermark textbox to the form from the toolbox. The watermark can be set on the properties browser tab "Tab" property or in code anywhere you need to set it.

Code: Select all

$Watermark_Leave={
	if($this.Text -eq "")
	{
		#Display the watermark
		$this.Text = $this.Tag # or assign a different source here
		$this.ForeColor = 'LightGray'
	}
}
This topic is 5 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