24 hour clock
Details
Date:10/15/2012 12:51:07 AM
Product:ActiveGanttVBN Gantt Chart / Scheduler Component
Framework:.Net Framework 4.0 / Visual Studio 2010
Version:2.9.2.0
User's Development Environment:Visual Basic .Net 2012
Subject:I want to Remove AM/PM from Lower Tier
Question

My client requires to remove AM/PM from lower tier of timeline and set time to 24 hour based.

I tried using custom lower tier and setting interval hourly based and factor set to 24 but the lower tier line went blank when i try to run it....

Please provide help about how should i fulfill this requirement...

Answer

Answer:

When setting a custom Tier, you must override the CustomTierDraw event, or else it will show up as black.

However in your situation it is not necessary to create a custom tier, you can use E_TIERTYPE.ST_HOUR.

The default View is drawn internally by the control with this code:


        Dim oView As clsView
        oView = ActiveGanttVBNCtl1.Views.Add(E_INTERVAL.IL_MINUTE, 1, E_TIERTYPE.ST_MONTH, E_TIERTYPE.ST_DAYOFWEEK, E_TIERTYPE.ST_DAYOFWEEK, "View1")
        oView.TimeLine.TierArea.MiddleTier.Visible = False
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_HOUR, 1, E_TICKMARKTYPES.TLT_BIG, True, "hh:mmtt")
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 30, E_TICKMARKTYPES.TLT_BIG)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 15, E_TICKMARKTYPES.TLT_MEDIUM)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 5, E_TICKMARKTYPES.TLT_SMALL)
        oView.TimeLine.TickMarkArea.Height = 30

        ActiveGanttVBNCtl1.CurrentView = "View1"
        ActiveGanttVBNCtl1.Redraw()

The caption on top of the hour is generated with the "hh:mmtt" format string. "hh" forces a twelve hour clock and "tt" includes the AM/PM designator. For more information on custom date/time format strings, visit http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx.

So the code you would need to modify the TickMark Area would be the following:


        Dim oView As clsView
        oView = ActiveGanttVBNCtl1.Views.Add(E_INTERVAL.IL_MINUTE, 1, E_TIERTYPE.ST_MONTH, E_TIERTYPE.ST_DAYOFWEEK, E_TIERTYPE.ST_DAYOFWEEK, "View1")
        oView.TimeLine.TierArea.MiddleTier.Visible = False
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_HOUR, 1, E_TICKMARKTYPES.TLT_BIG, True, "HH:mm")
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 30, E_TICKMARKTYPES.TLT_BIG)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 15, E_TICKMARKTYPES.TLT_MEDIUM)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 5, E_TICKMARKTYPES.TLT_SMALL)
        oView.TimeLine.TickMarkArea.Height = 30

        ActiveGanttVBNCtl1.CurrentView = "View1"
        ActiveGanttVBNCtl1.Redraw()

"HH" uses the 24 hour clock and we eliminate the "tt" part for the AM/PM designator.

But in your case you want the Tier, and not the TickMarkArea to display a 24 hour clock, so you can use this code:


        Dim oView As clsView
        oView = ActiveGanttVBNCtl1.Views.Add(E_INTERVAL.IL_MINUTE, 1, E_TIERTYPE.ST_MONTH, E_TIERTYPE.ST_DAYOFWEEK, E_TIERTYPE.ST_HOUR, "View1")
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_HOUR, 1, E_TICKMARKTYPES.TLT_BIG, True, "HH:mm")
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 30, E_TICKMARKTYPES.TLT_BIG)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 15, E_TICKMARKTYPES.TLT_MEDIUM)
        oView.TimeLine.TickMarkArea.TickMarks.Add(E_INTERVAL.IL_MINUTE, 5, E_TICKMARKTYPES.TLT_SMALL)
        oView.TimeLine.TickMarkArea.Height = 30

        ActiveGanttVBNCtl1.TierFormatScope = E_TIERFORMATSCOPE.TFS_CONTROL
        ActiveGanttVBNCtl1.TierFormat.HourIntervalFormat = "HH:mm"

        ActiveGanttVBNCtl1.CurrentView = "View1"
        ActiveGanttVBNCtl1.Redraw()

To hide the TickMarkArea just set it's visible property to false:


        Dim oView As clsView
        oView = ActiveGanttVBNCtl1.Views.Add(E_INTERVAL.IL_MINUTE, 1, E_TIERTYPE.ST_MONTH, E_TIERTYPE.ST_DAYOFWEEK, E_TIERTYPE.ST_HOUR, "View1")
        oView.TimeLine.TickMarkArea.Visible = False

        ActiveGanttVBNCtl1.TierFormatScope = E_TIERFORMATSCOPE.TFS_CONTROL
        ActiveGanttVBNCtl1.TierFormat.HourIntervalFormat = "HH:mm"

        ActiveGanttVBNCtl1.CurrentView = "View1"
        ActiveGanttVBNCtl1.Redraw()

 

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.