Disable menu Item

edited 11:39PM in FastReport .NET
Hi Alex,

How to disable the save as menu option at runtime?


Comments

  • StarkStark Syria
    edited 11:39PM
    Hi , have a good day ,

    Try this code



    FastReport.EnvironmentSettings frsetting = new FastReport.EnvironmentSettings();
    frsetting.DesignerSettings.Restrictions.DontSaveReport = true;
    
    // for test 
    // FastReport.Report report = new FastReport.Report();
    // report .Design();
    
    use the code above before loading your report ...
  • edited 11:39PM
    Stark wrote: »
    Hi , have a good day ,

    Try this code



    FastReport.EnvironmentSettings frsetting = new FastReport.EnvironmentSettings();
    frsetting.DesignerSettings.Restrictions.DontSaveReport = true;
    
    // for test 
    // FastReport.Report report = new FastReport.Report();
    // report .Design();
    
    use the code above before loading your report ...

    Hi,

    The above code disables the save and save as menu items.

    But I want to disable only the " Save as " menu item.

    Any ideas ?

    Also I have another doubt. If I load a report from a database, modify it and then click save, will the report be saved in the respective database ?

  • StarkStark Syria
    edited July 2010
    1)
    This code will make " Save as" menu inactive ..... NOT disable

    by adding a custom code , for the "save", "save as" menu
    // call this before load your report 
    private void InitSettings ()
    {
           EnvironmentSettings FastReportSetting = new EnvironmentSettings();
    
            FastReportSetting.DatabaseLogin += new DatabaseLoginEventHandler(FastReportSetting_DatabaseLogin);
            FastReportSetting.CustomSaveDialog += new FastReport.Design.OpenSaveDialogEventHandler(FastReportSetting_CustomSaveDialog);
            FastReportSetting.CustomSaveReport += new FastReport.Design.OpenSaveReportEventHandler(FastReportSetting_CustomSaveReport);
    }
    
    
    // put this any where in your form , or you class
     private static void FastReportSetting_CustomSaveReport(object sender, FastReport.Design.OpenSaveReportEventArgs e)
        {
            // e.Report.Save(e.FileName);
           // add your code to save report to database 
        }
    
        private static void FastReportSetting_CustomSaveDialog(object sender, FastReport.Design.OpenSaveDialogEventArgs e)
        {
            e.Cancel = true;  
        }
    //------------------------
    


    2) NO the saved report will not saved back to database , you need to add some code for doing that ...
    Like : convert report to string, o stream , and update the database through "FastReportSetting_CustomSaveReport" function in the previous code


    Hope this help
  • edited 11:39PM
    Hi,

    Thanks. I will give it a try and reply back.

    One more doubt.

    Is it possible to hide the code window in the designer?


    (I don't want my users to alter the code or even view it.)


  • edited 11:39PM
    Hello,

    No, it's not possible.
  • edited 11:39PM
    AlexTZ wrote: »
    Hello,

    No, it's not possible.

    Hi Alex,

    That's very disappointing.

    Is there any work around?
  • edited 11:39PM
    I need to add some flags to do this. I'll let you know when it will be ready.

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.