Open File Diaglog

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
superminhreturns
Posts: 1
Joined: Fri Mar 29, 2013 1:25 pm

Open File Diaglog

Post by superminhreturns » Fri Mar 29, 2013 4:38 pm

Hi,

I just purchase PowerShell Studio 2012 and I'm trying to get the hang of using the form creation.

I would like to better understand how to use the "Openfilediaglog" control.

Example:

How do I insert the Openfilediaglog into my form? I drag it over to my form however it goes to the bottom of the screen.

Sorry for the newb question.

Regards,

PeterT

User avatar
davidc
Posts: 5839
Joined: Thu Aug 18, 2011 4:56 am

Re: Open File Diaglog

Post by davidc » Fri Mar 29, 2013 6:16 pm

FYI I moved the post to the PowerShell GUI for since this is a question on a control and not the product itself.

The OpenFileDialog in the designer lets you set the filter and other properties. To show the dialog, you need to call it in your script. I recommend looking at the “TextBox - Browse for File” control set as an example.
PowerShell Code
Double-click the code block to select all.
$buttonBrowse_Click2={

	if($openfiledialog2.ShowDialog() -eq 'OK')
	{
		$textboxFile.Text = $openfiledialog2.FileName
	}
}
The MSDN Link for the OpenFileDialog:
http://msdn.microsoft.com/en-us/library ... ialog.aspx

For further GUI help I recommend reading this post:

http://www.sapien.com/forums/viewtopic.php?f=21&t=6451

It provides links to articles on GUI creation.

David
David
SAPIEN Technologies, Inc.

Locked