Report in the database

edited 5:27AM in FastReport .NET
Hi,
I decided to store a report in the database and i use version 1.0.229
I see the section in programmer's manual and i put EnvironmentSettings in my form (where is a DesignerControl).
I tried to replace CustomSaveDialog and CustomSaveReport events but nothing changes.
Have you a code example?

Thanks

Comments

  • edited 5:27AM
    Hello,

    I've modified the demo program in the following way, the dialogs work as expected. Note that I've used the Config.DesignerSettings instead of EnvironmentSettings component - this is the same:
        private void DesignReport()
        {
          if (FReport.IsRunning)
            return;
    
          Config.DesignerSettings.CustomOpenDialog += new OpenSaveDialogEventHandler(DesignerSettings_CustomOpenDialog);
          Config.DesignerSettings.CustomOpenReport += new OpenSaveReportEventHandler(DesignerSettings_CustomOpenReport);
          Config.DesignerSettings.CustomSaveDialog += new OpenSaveDialogEventHandler(DesignerSettings_CustomSaveDialog);
          Config.DesignerSettings.CustomSaveReport += new OpenSaveReportEventHandler(DesignerSettings_CustomSaveReport);
          
          FReport.Load((string)tvReports.SelectedNode.Tag);
          RegisterData();
          FReport.Design();
          PreviewReport();
        }
    
        void DesignerSettings_CustomOpenDialog(object sender, OpenSaveDialogEventArgs e)
        {
          using (OpenFileDialog dialog = new OpenFileDialog())
          {
            dialog.Title = "My Open Dialog";
            dialog.Filter = "Report files (*.frx)|*.frx";
            // set e.Cancel to false if dialog 
            // was succesfully executed
            e.Cancel = dialog.ShowDialog() != DialogResult.OK;
            // set e.FileName to the selected file name
            e.FileName = dialog.FileName;
          }
        }
    
        void DesignerSettings_CustomOpenReport(object sender, OpenSaveReportEventArgs e)
        {
          // load the report from the given e.FileName
          e.Report.Load(e.FileName);
        }
    
        void DesignerSettings_CustomSaveDialog(object sender, OpenSaveDialogEventArgs e)
        {
          using (SaveFileDialog dialog = new SaveFileDialog())
          {
            dialog.Title = "My Save Dialog";
            dialog.Filter = "Report files (*.frx)|*.frx";
            // get default file name from e.FileName
            dialog.FileName = e.FileName;
            // set e.Cancel to false if dialog 
            // was succesfully executed
            e.Cancel = dialog.ShowDialog() != DialogResult.OK;
            // set e.FileName to the selected file name
            e.FileName = dialog.FileName;
          }
        }
    
        void DesignerSettings_CustomSaveReport(object sender, OpenSaveReportEventArgs e)
        {
          // save the report to the given e.FileName
          e.Report.Save(e.FileName);
        }
    
  • edited 5:27AM
    Thanks, now it is working
  • edited 5:27AM
    Hello,

    i couldn't figure it out in VB.NET.
    Could you please post a sample?

    What components do i need on the relating form?

    i've declared a report-object in which i load a report.
    Private m_oReport As New FastReport.Report
    

    i placed also an environmentsettings-object on the form
    m_oFREnvironment
    

    i call the designer with
    m_oReport.Design(True)
    

    in the event i put the following to see when it gets fired
    Private Sub m_oFREnvironment_CustomOpenDialog(ByVal sender As System.Object, ByVal e As FastReport.Design.OpenSaveDialogEventArgs) Handles m_oFREnvironment.CustomOpenDialog
          MsgBox("Custom OpenDialog")
    End Sub
    

    but nothing happen.

    could please someone point me to the right direction.

    many thanx.
  • edited 5:27AM
    Hello,

    Unfortunately, EnvironmentSettings object is not working in VB.NET. Event handlers connected to this object will never fire. You need to use Config.DesignerSettings events instead, as indicated in the previous post sample. Here is equivalent VB.Net code (translated using Reflector utility):
      Private Sub DesignReport()
        If Not Me.FReport.IsRunning Then
          AddHandler Config.DesignerSettings.CustomOpenDialog, New OpenSaveDialogEventHandler(AddressOf Me.DesignerSettings_CustomOpenDialog)
          AddHandler Config.DesignerSettings.CustomOpenReport, New OpenSaveReportEventHandler(AddressOf Me.DesignerSettings_CustomOpenReport)
          AddHandler Config.DesignerSettings.CustomSaveDialog, New OpenSaveDialogEventHandler(AddressOf Me.DesignerSettings_CustomSaveDialog)
          AddHandler Config.DesignerSettings.CustomSaveReport, New OpenSaveReportEventHandler(AddressOf Me.DesignerSettings_CustomSaveReport)
          Me.FReport.Load(CStr(Me.tvReports.SelectedNode.Tag))
          Me.RegisterData
          Me.FReport.Design
          Me.PreviewReport
        End If
      End Sub
      
      Private Sub DesignerSettings_CustomOpenDialog(ByVal sender As Object, ByVal e As OpenSaveDialogEventArgs)
        Using dialog As OpenFileDialog = New OpenFileDialog
          dialog.Title = "My Open Dialog"
          dialog.Filter = "Report files (*.frx)|*.frx"
          e.Cancel = (dialog.ShowDialog <> DialogResult.OK)
          e.FileName = dialog.FileName
        End Using
      End Sub
    
      Private Sub DesignerSettings_CustomOpenReport(ByVal sender As Object, ByVal e As OpenSaveReportEventArgs)
        e.Report.Load(e.FileName)
      End Sub
    
      Private Sub DesignerSettings_CustomSaveDialog(ByVal sender As Object, ByVal e As OpenSaveDialogEventArgs)
        Using dialog As SaveFileDialog = New SaveFileDialog
          dialog.Title = "My Save Dialog"
          dialog.Filter = "Report files (*.frx)|*.frx"
          dialog.FileName = e.FileName
          e.Cancel = (dialog.ShowDialog <> DialogResult.OK)
          e.FileName = dialog.FileName
        End Using
      End Sub
    
      Private Sub DesignerSettings_CustomSaveReport(ByVal sender As Object, ByVal e As OpenSaveReportEventArgs)
        e.Report.Save(e.FileName)
      End Sub
    
  • edited 5:27AM
    Hello Alex,

    thank you for the quick response.

    it seems to work but now the Event gets fired wherever i addad the (global) EventHandler.
    So if i have added the eventhandler in 2 classes the events get always fired in both classes not only in the to the report corresponding.
    But this is actually no big problem - maybe you'll find a better solution in a future release.

    Is there a way to Import a Report from an File to an existing Report stored in a database??
  • edited 5:27AM
    Hello,

    These events are global, you need to attach them only once. Once you did this, the standard open/save dialogs will be replaced with your own.

    I don't know what you mean by importing one report to another. Please describe in details.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.