Removed options from Save button

RJPRJP
edited January 2017 in FastReport .NET
The subject says it all: How can I remove options from the toolbar Save button?

I know this question has been asked before, and I've seen a response suggesting finding the ButtonItem in the Preview.Toolbar and directly removing Subitems.

But that approach seems a bit fragile (if a new version comes along that changes these options, my code would break).

I have also seen a suggestion to use RegisteredObjects.FindObject(type).Enabled = false. But that just doesn't seem to do anything.

This is my code (in managed C++):
FastReport::Utils::RegisteredObjects::FindObject(
    FastReport::Export::RichText::RTFExport::typeid)->Enabled = false;
FastReport::Utils::RegisteredObjects::FindObject(
    FastReport::Cloud::StorageClient::Dropbox::DropboxStorageClient::typeid)->Enabled = false;

What am I doing wrong?

(PS: The report uses a PreviewControl that I create myself and assign to the Report->Preview property).

Comments

  • edited January 2017
    Do not use windows form designer, you must manually create fastreport component.
    public partial class Form1 : Form
    {
        private FastReport.Preview.PreviewControl previewControl1;
        private FastReport.Report report;
    
        public Form1()
        {
            // to initialize RegisteredObjects, you must do this before initializing PreviewControl
            report = new FastReport.Report();
            // get list of RegisteredObjects (i do this approach for experiment and learning)
            // you could use RegisteredObjects.FindObject
            List<FastReport.Utils.ObjectInfo> list = new List<FastReport.Utils.ObjectInfo>();
            FastReport.Utils.RegisteredObjects.Objects.EnumItems(list);
            // find object
            foreach (FastReport.Utils.ObjectInfo item in list)
            {                
                if (item.Object == typeof(FastReport.Export.RichText.RTFExport))
                {
                    // remove it from list
                    item.Enabled = false;
                    break;
                }
            }            
            InitializeComponent();
            // initializing PreviewControl
            previewControl1 = new FastReport.Preview.PreviewControl();
            previewControl1.BackColor = System.Drawing.SystemColors.AppWorkspace;
            previewControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            previewControl1.Font = new System.Drawing.Font("Tahoma", 8F);
            previewControl1.Location = new System.Drawing.Point(0, 0);
            previewControl1.Name = "previewControl1";
            previewControl1.PageOffset = new System.Drawing.Point(10, 10);
            previewControl1.Size = new System.Drawing.Size(617, 262);
            previewControl1.TabIndex = 0;
            previewControl1.UIStyle = FastReport.Utils.UIStyle.Office2003;
            this.Controls.Add(previewControl1);
        }
    }
    
  • RJPRJP
    edited 10:27AM
    Ah, I just wasn't using the RegisteredObjects early enough prior to the PreviewControl being created!

    Once I moved my code up, all worked ok.

    For the record, what I really wanted to do was remove all the Cloud-related save options, which I am now able to do with:
    for each(Utils::ObjectInfo^ info in Utils::RegisteredObjects::Objects->Items)
    	{
    		if (info->Object != nullptr && info->Object->AssemblyQualifiedName->StartsWith("FastReport.Cloud", true, nullptr))
    		{
    			info->Enabled = false;
    		}
    
    	}
    

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.