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

Open File Diaglog

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


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.


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.



User avatar
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.

	if($openfiledialog2.ShowDialog() -eq 'OK')
		$textboxFile.Text = $openfiledialog2.FileName
The MSDN Link for the OpenFileDialog: ... ialog.aspx

For further GUI help I recommend reading this post:

It provides links to articles on GUI creation.

SAPIEN Technologies, Inc.