Page 1 of 1

Closing Designer in Code in custom save window

Posted: Thu Oct 31, 2024 8:00 pm
by codemonkey
Hello,

i have a custom savehandler in which i open window where additional settings can be set and the report is saved into the database using this:

Code: Select all

AddHandler StiOptions.Engine.GlobalEvents.SavingReportInDesigner, AddressOf SaveReportHandler
I open the designer using

Code: Select all

ReportDesigner.DesignV2WithWpf()
In the handler the save dialog window is successfully opened.

Code: Select all

Private Sub SaveReportHandler(ByVal sender As Object, ByVal args As StiSavingObjectEventArgs)
Dim SpeichernDialog As New DesignerSpeichern()
If SpeichernDialog.ShowDialog() = DialogResult.OK Then
    args.Processed = True
    
    Dim test As New System.ComponentModel.CancelEventArgs
    test.Cancel = False
    StiOptions.Engine.GlobalEvents.InvokeClosingDesigner(ReportDesigner.Designer, test)
    Me.Close()
Else
    args.Processed = False
End If
End Sub
This works fine except one part the designer is still open.
How do i close the designer?
StiOptions.Engine.GlobalEvents.InvokeClosingDesigner(ReportDesigner.Designer, test) doesnt seem to work.

Re: Closing Designer in Code in custom save window

Posted: Thu Oct 31, 2024 8:20 pm
by Lech Kulikowski
Hello,

You can close the form with the designer component.

Thank you.

Re: Closing Designer in Code in custom save window

Posted: Thu Oct 31, 2024 9:26 pm
by codemonkey
Hello Lech,
thank you for the fast answer but i sadly dont understand it.

I looked through the ReportDesigner.Designer object for something recogniceable to close the window but could only find the InvokeClosingDesigner but that did nothing.
Can you please give me a line of code i can try?

Just for clarification:
Iam using the new WPF Components as our application moves away from winforms - with the winforms i got all that working.

When using ReportDesigner.DesignV2WithWpf() a new window is opened with the designer inside - it would also nice to open the designer into a panel or stackpanel instead of a new window but thats not cruical.
After clicking save or pressing ctrl+S my custom save window opens which is exactly as i want it to behave.
But after saving the report with my custom save window the designer stays open and has to be closed via the X on the right top.

Thanks again!

Re: Closing Designer in Code in custom save window

Posted: Mon Nov 04, 2024 12:35 pm
by Lech Kulikowski
Hello,

We need some additional time to investigate the issue, we will let you know about the result as soon as possible.

Thank you.
#15896

Re: Closing Designer in Code in custom save window

Posted: Mon Nov 04, 2024 2:49 pm
by codemonkey
Managed to solve it like this:

Code: Select all

Dim Parentobject = VisualTreeHelper.GetParent(ReportDesigner.Designer)
If Parentobject IsNot Nothing Then
    Parentobject = VisualTreeHelper.GetParent(Parentobject)
End If

If Parentobject IsNot Nothing Then
    Parentobject = VisualTreeHelper.GetParent(Parentobject)
End If

Dim myDesignerWindow = DirectCast(VisualTreeHelper.GetParent(Parentobject), System.Windows.Window)
If myDesignerWindow IsNot Nothing Then
    myDesignerWindow.Close()
End If

Re: Closing Designer in Code in custom save window

Posted: Tue Nov 05, 2024 8:34 pm
by Lech Kulikowski
Hello,

Thank you for sharing your experience with other users.