ReportDesigner - manual (how customize ReportDesigner)

edited September 2011 in FastReport .NET
I really need to customize buttons on ReportDesigner. I am considering to buy FastReport, but I need this feature.

I can easily hide buttons from previe control or add buttons on preview control. It is fantastic.
ButtonItem customButton = new ButtonItem();
customButton.Text = "my button";
customButton.Click += new EventHandler(customButton_Click);
preview.ToolBar.Items.Add(customButton);

I cannot found in manual even on forum, how to do the same on designer control. I just need to hide some buttons or override their functionality.

I need to hide Open, Save, Save All and override functionality on PREVIEW. How to to it please?

I found option to do it directly on designer, but I need to hide buttons in program - programmatically.
fastreport.png

Comments

  • edited 8:03AM
    Hello,

    Use this code:
          ToolbarBase standardToolbar = designerControl1.Plugins.Find("StandardToolbar") as ToolbarBase;
          standardToolbar.Items["btnStdOpen"].Visible = false;
          standardToolbar.Items["btnStdSave"].Visible = false;
          standardToolbar.Items["btnStdSaveAll"].Visible = false;
    
          designerControl1.cmdPreview.CustomAction += new EventHandler(cmdPreview_CustomAction);
    
        void cmdPreview_CustomAction(object sender, EventArgs e)
        {
          MessageBox.Show("Preview custom action");
        }
    

    Overriding the preview action is not working now due to the bug in this action. I will fix it tomorrow.
  • edited September 2011
    Thank you.
    And if it will be fixed, how it will be possible please to override action on preview button?
    Thank you.
  • edited 8:03AM
    See the code in the previous post. It's not working now, will be working in the tomorrow's build.
  • edited 8:03AM
    You mean this?
    designerControl1.cmdPreview.CustomAction += new EventHandler(cmdPreview_CustomAction);
    
        void cmdPreview_CustomAction(object sender, EventArgs e)
        {
          MessageBox.Show("Preview custom action");
        }
    

    But it is not override, but only add new event to existing one.
    But thank you, I will try it tommorrow.
  • edited 8:03AM
    No, this completely overrides the standard behavior.
  • edited 8:03AM
    Ok, thx.

    Behaviour of previewControl and designerControl is little different, but ok.I am trying now to acces to ContextMenu of SAVE button on PreviewControl.
    I am able to change caption - so i am able to acces to save button. But I dont know how to access to context menu.
    I want to hide SAVE button in FastReport PreviewControl but I want to add contextmenu and same on click functionality to my own button on formular.

    But i am not able to acces OnClick event or ContextMenu. Thanks for help.
    //i can hide save button
    m_previewControl.Buttons -= PreviewButtons.Save;
    
    //i can change caption of save button
    m_previewControl.ToolBar.Items["btnSave"].Text = "Just try to acces save button";
    

    I want to raise click, but it does'nt work. Is it possible to call click event and show context menu around my OWN BUTTON on different place on formular?
    //this does not work even if save button is visible or not
    m_previewControl.ToolBar.Items["btnSave"].RaiseClick();
    
  • edited 8:03AM
    The export menu is built dynamically. See the Demos\C#\CustomPreview project code how to display such menu for own button.

Leave a Comment