How to use SaveFileDialog?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have recently installed Visual Studio 2005 and although I'm starting to
understand the 64 bit differences, I seem to have run into another problem.

I would like to implement a simple "Save As.." dialog box, which back in the
day I remember was extremely simple, but now I can't find how I wrote the
code back then, and I don't understand how to use the .NET component
"SaveFileDialog".

In the help files it says that in order to use SaveFileDialog, one must use:
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
But I can't find how to manke use of those.

Could someone please point me in the direction of how to implement a "Save
As.." dialog?

Thank you.
 
There are some project settings you have to set up before you can use .Net.
If you created a new .Net project this is all done for you. If not, read on.

First you have to make sure you have the project set to use managed
extensions. This is in the General category in the project properties
dialog. After that you need to make sure you have a reference to the
assembly you need. Right click on the project name in solution explorer and
select Add Reference. This will bring up a dialog. Find the
System.Windows.Forms assembly and add it.

Now, in your source code you want to use the namespace, so near the top put
this:
using namespace System::Windows::Forms;

Now you should be all set to do the example found on MSDN
http://msdn.microsoft.com/library/e...ystemwindowsformssavefiledialogclasstopic.asp

As an alternative to the adding a reference thing you can use the following
line with your include files:
#using <System.Windows.Forms.dll>
 
Back
Top