CustomControl

How Can I Add Custom Control to My Filter Form?

Comments

  • edited 8:31PM
    Hello,

    You have to write a wrapper for this control. This is an example how standard LabelControl is implemented:
      /// <summary>
      /// Represents a standard Windows label.
      /// Wraps the <see cref="System.Windows.Forms.Label"/> control.
      /// </summary>
      public class LabelControl : DialogControl
      {
        private Label FLabel;
    
        #region Properties
        /// <summary>
        /// Gets an internal [b]Label[/b].
        /// </summary>
        [Browsable(false)]
        public Label Label
        {
          get { return FLabel; }
        }
    
        /// <summary>
        /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents.
        /// Wraps the <see cref="System.Windows.Forms.Label.AutoSize"/> property.
        /// </summary>
        [DefaultValue(true)]
        [Category("Layout")]
        public bool AutoSize
        {
          get { return Label.AutoSize; }
          set { Label.AutoSize = value; }
        }
    
        /// <summary>
        /// Gets or sets the alignment of text in the label.
        /// Wraps the <see cref="System.Windows.Forms.Label.TextAlign"/> property.
        /// </summary>
        [DefaultValue(ContentAlignment.TopLeft)]
        [Category("Appearance")]
        public ContentAlignment TextAlign
        {
          get { return Label.TextAlign; }
          set { Label.TextAlign = value; }
        }
        #endregion
    
        #region Public Methods
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
          LabelControl c = writer.DiffObject as LabelControl;
          base.Serialize(writer);
    
          if (AutoSize != c.AutoSize)
            writer.WriteBool("AutoSize", AutoSize);
          if (TextAlign != c.TextAlign)
            writer.WriteValue("TextAlign", TextAlign);
        }
        #endregion
    
        /// <summary>
        /// Initializes a new instance of the [b]LabelControl[/b] class with default settings. 
        /// </summary>
        public LabelControl()
        {
          FLabel = new Label();
          Control = FLabel;
          
          Label.AutoSize = true;
        }
      }
    

    Another way is to use script to add your control on the form. It can be done in the form.Load event:
        private void Form1_Load(object sender, EventArgs e)
        {
          Button myBtn = new Button();
          myBtn.Location = new System.Drawing.Point(10, 10);
          myBtn.Size = new System.Drawing.Size(100, 25);
          myBtn.Text = "My Button";
          myBtn.Parent = Form1.Form;
        }
    
  • edited 8:31PM
    Thanks 4 your reply
    is there away that I generate my filterstring in mu filter form an pass it to the report ;
    I define a public string Field in my filter form and set it with filter string;like this :
    public string FilterStatement = "[Detail.DetailID] == 2";

    and use it in data band filter but I found nothing
  • edited 8:31PM
    Set DataBand.Filter property in code:

    Data1.Filter = FilterStatement;
  • edited 8:31PM
    thanks because of you last answer ,
    now I wanna to save some meta data about a column when I set column.tag property and save the report , I see no tag info saved in the .frx file
  • edited 8:31PM
    Tag property of a column is not stored in the report file. It's not a problem to save it using .ToString(); it's a problem to restore original object (it will become a string after restore). That's why I don't store this property at all.
  • edited March 2009
    ok
    but where and how I can save my Column meta data in the report File .
    is description property of the report file good idea?
  • edited 8:31PM
    What kind of metadata do you want to save? Report.Description may be a good idea.
  • edited March 2009
    just string , I have some meta data about any column and I use them in my report generator that is based on fast report
  • edited 8:31PM
    Column.Tag cannot be used in your code, because it is used in FastReport to store some internal info. Consider using the Report.ReportInfo.Description property.
  • edited March 2009
    thanks

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.