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.
Locked
User avatar
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

textbox

Post by mqh777 » Fri Oct 26, 2018 7:52 am

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
Site Admin
Posts: 328
Joined: Sun Mar 03, 2013 12:42 pm

Re: textbox

Post by mxtrinidad » Fri Oct 26, 2018 8:25 am

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
Joined: Thu Aug 18, 2011 4:56 am

Re: textbox

Post by davidc » Fri Oct 26, 2018 8:32 am

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
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

Re: textbox

Post by mqh777 » Fri Oct 26, 2018 2:39 pm

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?

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: textbox

Post by jvierra » Fri Oct 26, 2018 2:56 pm

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'
	}
}

Locked