DevComponents in FastReport objects, ...

DomiDomi Belgium
edited 8:22AM in FastReport .NET
Hi,

I'm using DevCommponents too (nice components, good choice :-) ), I wanted to know if it's possible that the user components used and created inside the reports (forms, dialog, buttons, ...)
inherit from DevComponents to have the same look as my applications ?

thanks in advance,
Domi.

Comments

  • edited 8:22AM
    yes, you can, but limited to the version embedded in fastreport

    for example, in window forms:
            private void InitializeComponent()
            {
                ...
    
                this.DotNetBarButton = new FastReport.DevComponents.DotNetBar.ButtonItem();
                this.DotNetBarButton.Click += new System.EventHandler(this.DotNetBarButton_Click);
                this.PreviewControl1 = new FastReport.Preview.PreviewControl();
    
                ...
    
                //
                //DotNetBarButton
                //
                this.DotNetBarButton.ItemAlignment = FastReport.DevComponents.DotNetBar.eItemAlignment.Near;
                this.DotNetBarButton.ForeColor = System.Drawing.Color.Black;
                this.DotNetBarButton.Text = "Open Data";
                this.DotNetBarButton.ButtonStyle = FastReport.DevComponents.DotNetBar.eButtonStyle.ImageAndText;
                this.PreviewControl1.ToolBar.Items.Insert(1, DotNetBarButton);
    
                //
                //PreviewControl1
                //
                this.PreviewControl1.Anchor = (System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                    | System.Windows.Forms.AnchorStyles.Left)
                    | System.Windows.Forms.AnchorStyles.Right);
                this.PreviewControl1.Location = new System.Drawing.Point(0, 45);
                this.PreviewControl1.Margin = new System.Windows.Forms.Padding(5);
                this.PreviewControl1.Name = "PreviewControl1";
                this.PreviewControl1.PageOffset = new System.Drawing.Point(10, 10);
                this.PreviewControl1.Size = new System.Drawing.Size(1008, 477);
                this.PreviewControl1.TabIndex = 0;
                this.Controls.Add(this.PreviewControl1);
    
                ...
            }
            internal FastReport.Preview.PreviewControl PreviewControl1;
            internal FastReport.DevComponents.DotNetBar.ButtonItem DotNetBarButton;
    
  • DomiDomi Belgium
    edited 8:22AM
    Thanks for that ipong but your code is how I can use the DevComponent controls (from fastreport) in MY application; what I want is how I can use the DevComponent directly INSIDE the reports, from here :

    in the following, "MyForm" should have the look and theme from DevComponent and what i have choosen in my main application.

  • edited 8:22AM
    1. add a reference : FastReport.Bars.dll (menu Report=>Options=Script)
    2. add dialog form, with name = Form1
    3. in report script, create a wrapper for devcomponent, for example : button
      public class ReportScript
      {
        private void Form1_Load(object sender, EventArgs e)
        {
          DotNetBarButtonControl button = new DotNetBarButtonControl();
          FastReport.DevComponents.DotNetBar.ButtonX properties = button.Button;
          properties.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
          properties.ColorTable = FastReport.DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
          properties.Location = new System.Drawing.Point(0, 0);
          properties.Size = new System.Drawing.Size(75, 23);
          properties.Style = FastReport.DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
          properties.Text = "Click Me";
          properties.Click += new System.EventHandler(button_Click);
          Form1.Controls.Add(button);
        }
        
        private void button_Click(object sender, EventArgs e)
        {
          MessageBox.Show("Hello World");
        }
      }
      
      public class DotNetBarButtonControl : FastReport.Dialog.DialogControl
      {
        private FastReport.DevComponents.DotNetBar.ButtonX _button;
        
        public FastReport.DevComponents.DotNetBar.ButtonX Button
        {
          get
          {
            return this._button;
          }
        }
        
        public DotNetBarButtonControl()
        {
          this._button = new FastReport.DevComponents.DotNetBar.ButtonX();
          base.Control = this._button;
        }
      }
    
    4. that's all, run it

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.