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

creating tables in subreports

4 Answers 147 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 09 Feb 2009, 03:51 AM
Hi all;

I am trying to add a table/grid (like radgridview) on my subreports and this table would grow up to 10 rows depending on the information from a database.(also the position of the table in the subreport will be important) I tried to achieve this by adding bordered textboxes next to each other and make them look like a table, but I couldn't add text boxes to my subreports programmatically.

At the below link, I have added a screen shot of what I am trying to achieve.
http://img220.imageshack.us/my.php?image=samplesu4.jpg

I was wondering if it is possible to achieve this, and what would be the best approach. (If you have an example, that would be marvellous)

Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 10 Feb 2009, 03:56 AM
i was able to add textboxes to subreports programmatically, but still wondering if there is a better way to implement a table/grid within a subreport at runtime. By the way, I am trying to implement a vb windows forms program, not a web based program.

Thank you.
0
Janus Pedersen
Top achievements
Rank 2
answered on 12 Feb 2009, 01:19 PM
Hi
You can use panels and textboxs. 
1.  Define the panel (size and so) and the textbox
2. Sæt the size and the doc of the textbox
3. Add the textbox the panel
4. Add the panel to the detail sektion

Small sample: Just put in AddRow("Type""Type""Adress","Phone"); in your code.
        /// <summary>  
        /// Make a row and put it in detail sektoin 
        /// </summary>  
        /// <param name="str1">Type</param>  
        /// <param name="str2">Name</param>  
        /// <param name="str3">Adress</param>  
        /// <param name="str4">Phone</param>  
        public void AddRow(string str1, string str2, string str3, string str4)  
        {  
            if (str1 == null)  
            {  
                str1 = "";  
            }  
 
            if (str2 == null)  
            {  
                str2 = "";  
            }  
            if (str3 == null)  
            {  
                str3 = "";  
            }  
            if (str4 == null)  
            {  
                str4 = "";  
            }  
 
            // Oprettelse af paneler  
            var panel_1 = new Panel  
            {  
                Size =  
                    new SizeU(  
                    new Unit(15,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Dock = DockStyle.Right,  
                Style = { BorderStyle = { Default = BorderType.Solid } }  
            };  
            var panel_3 = new Panel  
            {  
                Width = new Unit(15, UnitType.Cm),  
                Height = new Unit(0.5, UnitType.Cm),  
                Style = { BorderStyle = { Left = BorderType.None } },  
                Dock = DockStyle.Left  
            };  
            var panel_4 = new Panel { Dock = DockStyle.Right };  
 
            // Oprettelse af tekstbokse  
            var textBox_7 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str1,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_8 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str2,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_9 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str3,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_10 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str4,  
                Dock = DockStyle.Right  
            };  
 
            panel_3.Items.AddRange(new ReportItemBase[] { textBox_7, textBox_9, textBox_8, textBox_10 });  
 
            panel_1.Items.AddRange(new ReportItemBase[] { panel_3 });  
            panel_1.Dock = DockStyle.Top;  
 
            if (str2.Length < 2 && str3.Length < 2 && str4.Length < 2)  
            {  
                panel_1.Style.BorderStyle.Default = BorderType.None;  
                panel_3.Style.BorderStyle.Left = BorderType.None;  
                textBox_9.Style.BorderStyle.Left = BorderType.None;  
                textBox_8.Style.BorderStyle.Left = BorderType.None;  
                // textBox_7.Style.BorderStyle.Left = BorderType.None;  
                textBox_10.Style.BorderStyle.Left = BorderType.None;  
                //textBox_10.Style.BorderStyle.Right = BorderType.Solid;  
                panel_1.Style.BorderStyle.Right = BorderType.Solid;  
                textBox_7.Style.Font.Bold = true;  
            }  
 
            if (detail != null)  
                detail.Items.Add(panel_1);  
        }  
 

Janus S. Andersen
0
Jacob
Top achievements
Rank 1
answered on 12 Feb 2009, 05:18 PM
Hi Janus,

Thank you for the reply, but it is giving the following error:

{"Cannot add  (Telerik.Reporting.Panel) to detail (Telerik.Reporting.DetailSection)."}

Thanks
0
Janus Pedersen
Top achievements
Rank 2
answered on 13 Feb 2009, 09:39 AM
Hi
Just put it in in the using - part.

 

using Panel = Telerik.Reporting.Panel;   
using TextBox = Telerik.Reporting.TextBox; 

Janus S. Andersen

 

Tags
General Discussions
Asked by
Jacob
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Janus Pedersen
Top achievements
Rank 2
Share this question
or