Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create custom report controls

$
0
0

The following example demonstrates how to create a custom ProgressBar control.

In this example, the progress bar control is implemented as a filled rectangle with variable width, and serves as a graphical representation of a numerical value. This custom control has two primary properties - Position and MaxValue. The Position property determines the current progress for the value tracked by this control (how much of the bar is filled in with the progress color). The MaxValue property determines the maximum value for the Position property and the scale used by the progress bar. Note that the Position property is bindable, which allows the progress bar control to be used in data-aware reports.

Question Comments

Added By: Jignesh Suthar at: 4/18/2013 10:26:52 AM    

How do I specify editor for the Numeric property in below example?

Added By: Wolfgang Lautner at: 7/31/2014 7:02:23 AM    

I tried this example and when changing the base class from XRLabel to XRControl, then also the "Preview" worked (exception unable to cast PanelBrick to LabelBrick)

Then I tried to make a custom control how described in the tutorial "How to: Create a Progress Bar Control", but when loading the DLL to add the control to the toolbox, it failed with the error "There is no components in '...dll' that can be placed on the toolbox.

Any idea what is going wrong or can you provide an example project to build a working control dll?

Regards, Wolfgang

Added By: Vasily (DevExpress Support) at: 7/31/2014 10:31:56 AM    

Hi Wolfgang,

To process your recent post more efficiently, I created a separate ticket on your behalf: T135838: How to create a custom report control and register in in the ToolBox. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Justyn Laufenberg at: 10/14/2014 1:35:29 PM    

When the report is saved and loaded again, if max value was set to something besides 100, it doesnt save. Is there a way to get the properties to save as part of the xml? I am using the end user side of reports and need the custom properties to save when 'SaveLayoutToXml' is called.

Added By: Ingvar (DevExpress Support) at: 10/15/2014 1:27:43 AM    Hi Justyn,

Make sure that you have marked your properties with the XtraSerializableProperty attribute.

See also:
XML SerializationAdded By: Justyn Laufenberg at: 10/15/2014 8:06:27 AM    

Awesome, easy fix. For others reference.

       [DefaultValue(100), XtraSerializableProperty]
       public float MaxValue {
           get { return this.maxVal; }
           set {
               if (value <= 0) return;
               this.maxVal = value;
           }
       }

Added By: Justyn Laufenberg at: 10/15/2014 9:21:19 AM    

Another Question, how do we set what the display name of the control will be in the toolbox?

For the properties, I was able to do the following.
[DisplayName("Max Value")]
[Description("The max value of the bar.")]

But the same doesn't work for the control. I would like it to say "Progress Bar".  Currently, I am doing the following but is a little tedious and would like to know if there is a better way.
ToolboxItem progressBar= new ToolboxItem(typeof(ProgressBar));
progressBar.DisplayName = "Progress Bar";
ts.AddToolboxItem(progressBar, "Custom");

Thank You.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>