How to show only a fixed time in the ActiveGantt Scheduler Component
Details
Date:2/4/2013 1:06:20 AM
Product:ActiveGanttVBN Gantt Chart / Scheduler Component
Framework:.Net Framework 4.0 / Visual Studio 2010
Version:2.9.3.0
User's Development Environment:Visual Basic .Net 2012
Subject:Could you provide an example on how to set a week view (8 days) in any resolution of the screen
Question

As my client's requirement, I want to show only 8 days for a week view in any resolution of screen. could you give me some examples to show a view of week (8 days) in any resolution.

i have created different views on scheduler to show a day, week, month, year, ... on a screen they are working perfectly on resolution of 1152x864, but when I change resolution of screen, the duration is changed.

The below code will show me a week(8 days) in scheduler control on resolution of 1152x864 but for higher resolution (i.e. 1600x1200) it show me 10 to12 days on week view.


         ' ( For 1 Week )
        oView = AGVBN_Scheduler.Views.Add(E_INTERVAL.IL_MINUTE, 12, E_TIERTYPE.ST_CUSTOM, E_TIERTYPE.ST_CUSTOM, E_TIERTYPE.ST_CUSTOM, "View6")
        oView.TimeLine.TierArea.UpperTier.Interval = E_INTERVAL.IL_MONTH
        oView.TimeLine.TierArea.UpperTier.Factor = 1
        oView.TimeLine.TierArea.UpperTier.Height = 25
        oView.TimeLine.TierArea.MiddleTier.Interval = E_INTERVAL.IL_DAY
        oView.TimeLine.TierArea.MiddleTier.Factor = 1
        oView.TimeLine.TierArea.MiddleTier.Height = 20
        oView.TimeLine.TierArea.LowerTier.Visible = False
        oView.TimeLine.TickMarkArea.Visible = False
        oView.TimeLine.StyleIndex = "TimeLine"
        oView.ClientArea.DetectConflicts = False
        oView.Tag = "1 Week"
Answer

Answer:

It's an interesting question.

The following code will only show 8 hours, regardless if the windows form hosting the ActiveGantt Scheduler Component is re-sized. This code is not exact, it will sometimes show a few minutes more or a few minutes less:


    Private Sub fResizing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        ActiveGanttVBNCtl1.Columns.Add("Column 1", "", 125, "")
        For i = 0 To 100
            ActiveGanttVBNCtl1.Rows.Add("K" & i.ToString(), "Row " & i.ToString, True, True, "")
        Next
        ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.Position(New AGVBN.DateTime(2013, 1, 1))
        mp_OnResize()
    End Sub

    Private Sub fResizing_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        mp_OnResize()
    End Sub

    Private Sub mp_OnResize()
        ActiveGanttVBNCtl1.Left = 0
        ActiveGanttVBNCtl1.Top = 0
        ActiveGanttVBNCtl1.Width = Me.ClientSize.Width
        ActiveGanttVBNCtl1.Height = Me.ClientSize.Height
        Dim lTLWidth As Integer = ActiveGanttVBNCtl1.MathLib.GetXCoordinateFromDate(ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.EndDate) - ActiveGanttVBNCtl1.MathLib.GetXCoordinateFromDate(ActiveGanttVBNCtl1.CurrentViewObject.TimeLine.StartDate)
        If lTLWidth > 100 Then
            Dim lSeconds As Integer = 60 * 60 * 8 '8 Hours
            ActiveGanttVBNCtl1.CurrentViewObject.Interval = AGVBN.E_INTERVAL.IL_SECOND
            ActiveGanttVBNCtl1.CurrentViewObject.Factor = lSeconds / lTLWidth
        End If
    End Sub

To use this code just drag an ActiveGanttVBN control onto a Windows Form and override the Load and Resize events.

 

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.