SaveFileDialog from DLL?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amjad

    #1

    SaveFileDialog from DLL?

    I'm writing a DLL code that has routines, one of which creates an Excel file
    and saves it, if certain conditions are met. I want the main project in the
    solution to call that routine in the DLL to create the file and I want the
    user to specify the file name and location using the SaveFileDialog before
    saving the file.

    PS. In the DLL routine there are code lines that have to be executed before
    and after calling the SaveFileDialog.

    Is there a way to call the SaveFileDialog control from a dll ?
  • Herfried K. Wagner [MVP]

    #2
    Re: SaveFileDialog from DLL?

    "Amjad" <Amjad@discussi ons.microsoft.c om> schrieb:[color=blue]
    > In the DLL routine there are code lines that have to be executed before
    > and after calling the SaveFileDialog.
    >
    > Is there a way to call the SaveFileDialog control from a dll ?[/color]

    Add a reference to "System.Windows .Forms.dll" to the class library project,
    then import the 'System.Windows .Forms' namespace and use the class:

    \\\
    Public Sub Foo()
    ...
    Dim o As New SaveFileDialog( )
    If o.ShowDialog() = DialogResult.OK Then
    ...
    End If
    o.Dispose()
    ...
    End Sub
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Amjad

      #3
      Re: SaveFileDialog from DLL?

      Thank you Herfried. You answered my question.

      I have a follow-up question though. Can I change/access any of the controls'
      properties on the MainForm Project from my class library project (DLL)?

      for example can I set the Enabled property of a TextBox to False from my DLL
      program?


      "Herfried K. Wagner [MVP]" wrote:
      [color=blue]
      > "Amjad" <Amjad@discussi ons.microsoft.c om> schrieb:[color=green]
      > > In the DLL routine there are code lines that have to be executed before
      > > and after calling the SaveFileDialog.
      > >
      > > Is there a way to call the SaveFileDialog control from a dll ?[/color]
      >
      > Add a reference to "System.Windows .Forms.dll" to the class library project,
      > then import the 'System.Windows .Forms' namespace and use the class:
      >
      > \\\
      > Public Sub Foo()
      > ...
      > Dim o As New SaveFileDialog( )
      > If o.ShowDialog() = DialogResult.OK Then
      > ...
      > End If
      > o.Dispose()
      > ...
      > End Sub
      > ///
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://classicvb.org/petition/>
      >
      >[/color]

      Comment

      Working...