This is a migrated thread and some comments may be shown as answers.

Simpler way of initializing Reporting element?

0 Answers 18 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gureumi
Top achievements
Rank 1
gureumi asked on 09 Nov 2010, 08:49 PM
I'd like to find a simpler(and better) way of initializing an element.

Let me take an example of TextBox.
Because of Type conversion and etc. It is quite messy.

The following code is what I have as a solution. I used extension method.

Is Telerik going to provide something similar to this?


     double leftPoint = 0;
       double Y_FirstLine = 0.02;
     double width = 1.25;
     double height  = 0.25;
 
     Telerik.Reporting.TextBox textBox;
 
      // Add ItemInfoId Box
      textBox = new Telerik.Reporting.TextBox();        
      textBox.SetTextBoxAttribute("ItemId", leftPoint, Y_FirstLine, width, height);
      groupHeaderSection1.Items.Add(textBox);
 
      // Add Cost  Box
      leftPoint +=  0.6;
      textBox = new Telerik.Reporting.TextBox();
      textBox.SetTextBoxAttribute("COST", leftPoint, Y_FirstLine, width, height);
      groupHeaderSection1.Items.Add(textBox);

                  // a lot more of TextBoxes ... 
 
 
public static class TextBoxExtension
{
   public static void SetTextBoxAttribute(
         this Telerik.Reporting.TextBox  itemBox,
         string value, double left, double top, double width, double height)
   {
      itemBox.Value = value;
      itemBox.Location = new Telerik.Reporting.Drawing.PointU(
        new Telerik.Reporting.Drawing.Unit(left, Telerik.Reporting.Drawing.UnitType.Inch),
        new Telerik.Reporting.Drawing.Unit(top, Telerik.Reporting.Drawing.UnitType.Inch));
      itemBox.Size = new Telerik.Reporting.Drawing.SizeU(
        new Telerik.Reporting.Drawing.Unit(width, Telerik.Reporting.Drawing.UnitType.Inch),
        new Telerik.Reporting.Drawing.Unit(
             height, Telerik.Reporting.Drawing.UnitType.Inch));
   }
}

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
gureumi
Top achievements
Rank 1
Share this question
or