Question regarding Column merging in the Gantt Chart control
Details
Date:1/13/2010 6:25:10 AM
Product:ActiveGanttVBN Gantt Chart / Scheduler Component
Framework:.Net Framework 1.0
Version:2.8.0
User's Development Environment:Visual Basic .Net 2002
Subject:Question regarding cell merging
Question

I have recently downloaded the trial version of ActiveGanttVBN and have been evaluating whether or not this product will meet the needs of my project. The overall goal of this chart is to schedule projects in our various QA environments. However, multiple projects can coexist in the same environment during the same time frame. Is it possible to merge cells in the leading column across multiple rows? Attached is a sample of what I am hoping to achieve.

Answer

Answer:

In the onload event of the form place the following code:

 
       Dim oStyle As AGVBN.clsStyle
        Dim oStyleHeading As AGVBN.clsStyle
        Dim oTask1 As AGVBN.clsStyle
        Dim oTask2 As AGVBN.clsStyle
        Dim oTask3 As AGVBN.clsStyle
        Dim oTask4 As AGVBN.clsStyle
        Dim oTask5 As AGVBN.clsStyle
        Dim oTask6 As AGVBN.clsStyle
        Dim oTask7 As AGVBN.clsStyle

        oStyle = ActiveGanttVBNCtl1.Styles.Add("LowerTier")
        oStyle.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Regular)
        oStyle.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oStyle.BackColor = Color.White
        oStyle.BorderStyle = AGVBN.GRE_BORDERSTYLE.SBR_SINGLE

        oStyleHeading = ActiveGanttVBNCtl1.Styles.Add("HeadingStyle")
        oStyleHeading.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oStyleHeading.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oStyleHeading.BackColor = Color.LightGray
        oStyleHeading.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask1 = ActiveGanttVBNCtl1.Styles.Add("Task1")
        oTask1.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask1.OffsetTop = 0
        oTask1.OffsetBottom = 20
        oTask1.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask1.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask1.BackColor = Color.FromArgb(51, 153, 254)

        oTask2 = ActiveGanttVBNCtl1.Styles.Add("Task2")
        oTask2.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask2.OffsetTop = 0
        oTask2.OffsetBottom = 20
        oTask2.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask2.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask2.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask2.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask2.EndGradientColor = Color.FromArgb(207, 116, 255)
        oTask2.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask2.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask3 = ActiveGanttVBNCtl1.Styles.Add("Task3")
        oTask3.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask3.OffsetTop = 0
        oTask3.OffsetBottom = 20
        oTask3.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask3.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask3.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask3.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask3.EndGradientColor = Color.FromArgb(10, 158, 255)
        oTask3.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask3.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask4 = ActiveGanttVBNCtl1.Styles.Add("Task4")
        oTask4.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask4.OffsetTop = 0
        oTask4.OffsetBottom = 20
        oTask4.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask4.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask4.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask4.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask4.EndGradientColor = Color.FromArgb(45, 190, 111)
        oTask4.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask4.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask5 = ActiveGanttVBNCtl1.Styles.Add("Task5")
        oTask5.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask5.OffsetTop = 20
        oTask5.OffsetBottom = 20
        oTask5.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask5.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask5.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask5.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask5.EndGradientColor = Color.FromArgb(162, 208, 255)
        oTask5.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask5.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask6 = ActiveGanttVBNCtl1.Styles.Add("Task6")
        oTask6.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask6.OffsetTop = 40
        oTask6.OffsetBottom = 20
        oTask6.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask6.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask6.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask6.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask6.EndGradientColor = Color.FromArgb(45, 190, 111)
        oTask6.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask6.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE

        oTask7 = ActiveGanttVBNCtl1.Styles.Add("Task7")
        oTask7.Placement = AGVBN.Globals.E_PLACEMENT.PLC_OFFSETPLACEMENT
        oTask7.OffsetTop = 0
        oTask7.OffsetBottom = 20
        oTask7.Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold)
        oTask7.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_FLAT
        oTask7.BackGroundMode = AGVBN.Globals.GRE_BACKGROUNDMODE.FP_GRADIENT
        oTask7.StartGradientColor = Color.FromArgb(255, 255, 255)
        oTask7.EndGradientColor = Color.FromArgb(255, 167, 33)
        oTask7.GradientFillMode = AGVBN.Globals.GRE_GRADIENTFILLMODE.GDT_VERTICAL
        oTask7.BorderStyle = AGVBN.Globals.GRE_BORDERSTYLE.SBR_NONE




        ActiveGanttVBNCtl1.Columns.Add("Environment")
        ActiveGanttVBNCtl1.Columns.Item(1).Style.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_CELL
        ActiveGanttVBNCtl1.Columns.Item(1).Style.BackColor = Color.White
        ActiveGanttVBNCtl1.Columns.Item(1).Style.TextAlignmentVertical = AGVBN.Globals.GRE_VERTICALALIGNMENT.VAL_BOTTOM
        ActiveGanttVBNCtl1.Rows.Add("O1", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K1", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K2", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K3", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K4", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K5", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K6", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K7", "", False)
        ActiveGanttVBNCtl1.Rows.Add("K8", "", False)

        ActiveGanttVBNCtl1.Rows.Item(1).Height = 20
        ActiveGanttVBNCtl1.Rows.Item(4).Height = 80

        ActiveGanttVBNCtl1.Rows.Item(2).Cells.Item(1).Text = "Misc"
        ActiveGanttVBNCtl1.Rows.Item(3).Cells.Item(1).Text = "US - 1"
        ActiveGanttVBNCtl1.Rows.Item(4).Cells.Item(1).Text = "US - 2"

        ActiveGanttVBNCtl1.Rows.Item(5).Cells.Item(1).Text = "US - 3"
        ActiveGanttVBNCtl1.Rows.Item(6).Cells.Item(1).Text = "US - 4"
        ActiveGanttVBNCtl1.Rows.Item(7).Cells.Item(1).Text = "US - 5"
        ActiveGanttVBNCtl1.Rows.Item(8).Cells.Item(1).Text = "UK - 1"
        ActiveGanttVBNCtl1.Rows.Item(9).Cells.Item(1).Text = "UK - 2"

        ActiveGanttVBNCtl1.CurrentViewObject.Interval = "30n"
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.Style.Appearance = AGVBN.Globals.E_STYLEAPPEARANCE.SA_CELL
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.Style.BackColor = Color.White
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.TierArea.UpperTier.Interval = "1d"
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.TierArea.LowerTier.TierType = AGVBN.Globals.E_TIERTYPE.ST_CUSTOM
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.TickMarkArea.Visible = False
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.TierArea.LowerTier.Height = 40
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.TierArea.UpperTier.Visible = False
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.Position(New DateTime(2010, 1, 6))

        ActiveGanttVBNCtl1.CurrentViewObject.ClientArea.Grid.Interval = "1d"
        ActiveGanttVBNCtl1.CurrentViewObject.ClientArea.Grid.VerticalLines = True
        ActiveGanttVBNCtl1.CurrentViewObject.ClientArea.Grid.SnapToGrid = True



        ActiveGanttVBNCtl1.Tasks.Add("Kelly/Ben", "O1", New DateTime(2010, 1, 6), New DateTime(2010, 1, 9), "H1", "HeadingStyle")
        ActiveGanttVBNCtl1.Tasks.Add("Rob/Raf", "O1", New DateTime(2010, 1, 11), New DateTime(2010, 1, 16), "H2", "HeadingStyle")
        ActiveGanttVBNCtl1.Tasks.Add("Carl/Jim", "O1", New DateTime(2010, 1, 18), New DateTime(2010, 1, 23), "H3", "HeadingStyle")
        ActiveGanttVBNCtl1.Tasks.Add("", "K2", New DateTime(2010, 1, 6), New DateTime(2010, 1, 7), "T1", "Task1")
        ActiveGanttVBNCtl1.Tasks.Add("123 - Dry Run", "K2", New DateTime(2010, 1, 16), New DateTime(2010, 1, 20), "T2", "Task2")

        ActiveGanttVBNCtl1.Tasks.Add("123 - Test Project 1", "K3", New DateTime(2010, 1, 6), New DateTime(2010, 1, 12), "T3", "Task3")
        ActiveGanttVBNCtl1.Tasks.Add("123 - UAT", "K3", New DateTime(2010, 1, 12), New DateTime(2010, 1, 16), "T4", "Task4")
        ActiveGanttVBNCtl1.Tasks.Add("456 - Another Project", "K3", New DateTime(2010, 1, 8), New DateTime(2010, 1, 13), "T5", "Task5")
        ActiveGanttVBNCtl1.Tasks.Add("789 - Third Project", "K3", New DateTime(2010, 1, 12), New DateTime(2010, 1, 19), "T6", "Task6")

        ActiveGanttVBNCtl1.Tasks.Add("- Refresh ENV", "K5", New DateTime(2010, 1, 6), New DateTime(2010, 1, 9), "T7", "Task7")

And override the CustomTierDraw event:


    Private Sub ActiveGanttVBNCtl1_CustomTierDraw(ByVal sender As Object, ByVal e As AGVBN.CustomTierDrawEventArgs) Handles ActiveGanttVBNCtl1.CustomTierDraw
        If e.TierPosition = AGVBN.Globals.E_TIERPOSITION.SP_LOWER Then
            e.Text = e.StartDate.Month & "/" & e.StartDate.Day
            e.StyleIndex = "LowerTier"
        End If
    End Sub

As you can see it’s really just a question of using styles. You can also place tasks in different layers to avoid conflicts.

Here you can see the final output:

 

All trademarks are property of their respective holders, and are only used to directly describe the products and services being provided. Their use in no way indicates any relationship or endorsement between The Source Code Store LLC and the holders of said trademarks.