Reports for WinForms | ComponentOne
In This Topic
    Rendering Overlapping Objects in a Table
    In This Topic

    You can easily render overlapping objects in a table cell. For example, add the following code to the Form_Load event before the Generate method to add a square overlapped by two crossing lines in the table:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Create a rectangle, and two lines to form an 'X'.     
    Dim rect As New RenderRectangle(New Unit(3, UnitTypeEnum.Cm), New Unit(3, UnitTypeEnum.Cm))    
    Dim rl1 As New RenderLine(New Unit(0, UnitTypeEnum.Cm), New Unit(0, UnitTypeEnum.Cm), New Unit(3, UnitTypeEnum.Cm), New Unit(3, UnitTypeEnum.Cm), LineDef.[Default])    
    Dim rl2 As New RenderLine(New Unit(3, UnitTypeEnum.Cm), New Unit(0, UnitTypeEnum.Cm), New Unit(0, UnitTypeEnum.Cm), New Unit(3, UnitTypeEnum.Cm), LineDef.[Default])    
    rect.Style.BackColor = Color.PeachPuff
    
    ' Add the objects to the table.    
    table.Cells(1, 1).Area.Children.Add(rect)    
    table.Cells(1, 1).Area.Children.Add(rl1)    
    table.Cells(1, 1).Area.Children.Add(rl2)
    

    To write code in C#

    C#
    Copy Code
    // Create a rectangle, and two lines to form an 'X'.     
    RenderRectangle rect = new RenderRectangle(new Unit(3, UnitTypeEnum.Cm), new Unit(3, UnitTypeEnum.Cm));    
    RenderLine rl1 = new RenderLine(new Unit(0, UnitTypeEnum.Cm), new Unit(0, UnitTypeEnum.Cm), new Unit(3, UnitTypeEnum.Cm), new Unit(3, UnitTypeEnum.Cm), LineDef.Default);    
    RenderLine rl2 = new RenderLine(new Unit(3, UnitTypeEnum.Cm), new Unit(0, UnitTypeEnum.Cm), new Unit(0, UnitTypeEnum.Cm), new Unit(3, UnitTypeEnum.Cm), LineDef.Default);    
    rect.Style.BackColor = Color.PeachPuff;
        
    // Add the objects to the table.     
    table.Cells[1, 1].Area.Children.Add(rect);    
    table.Cells[1, 1].Area.Children.Add(rl1);    
    table.Cells[1, 1].Area.Children.Add(rl2);
    

    What You've Accomplished

    The table appears with a square with two overlapping lines: