Page 1 of 1

System setting file lookup

PostPosted: Mon Dec 17, 2018 2:34 pm
by pricerc
I'm wanting to add a file 'open' dialog to system settings, to provide a simple 'user-friendly' way to get a file name into a system setting.

I suppose the same logic would apply to a custom form field.

Any pointers/examples?

Re: System setting file lookup  Topic is solved

PostPosted: Mon Dec 17, 2018 3:32 pm
by pricerc
To answer my own question:

Code: Select all
Public Class SystemSettingPlugin
      Inherits System.MarshalByRefObject
      Implements JiwaApplication.IJiwaSystemSettingPlugin
'.
'. bits left out that don't matter.
'.

        Public Sub ButtonClicked(ByVal BusinessLogicHost As JiwaApplication.IJiwaBusinessLogic, ByVal GridObject As JiwaApplication.Controls.JiwaGrid, ByVal FormObject As JiwaApplication.IJiwaForm, ByVal Col As Integer, ByVal Row As Integer, ByVal SystemSetting As JiwaApplication.SystemSettings.Setting) Implements JiwaApplication.IJiwaSystemSettingPlugin.ButtonClicked
'             If Debugger.IsAttached Then Debugger.Break()
            If SystemSetting.IDKey = "Invoice Email Report Filename" Then
                Dim newFileDialog As OpenFileDialog = New OpenFileDialog() With {
                    .FileName = SystemSetting.Contents,
                    .CheckFileExists = True,
                    .DefaultExt = "RPT",
                    .Filter = "Crystal Reports (*.RPT)|*.RPT|All Files (*.*)|*,*",
                    .Multiselect = False,
                    .RestoreDirectory = True,
                    .SupportMultiDottedExtensions = True,
                    .DereferenceLinks = True
                }
                If newFileDialog.ShowDialog() = DialogResult.OK Then
                    SystemSetting.Contents = newFileDialog.FileName
                End If
            End If
        End Sub

   End Class


There's probably fancier stuff that could be done, but this has worked for me.