The Straight Tip


... on VARCHART XGantt:
How to Display Nodes and Groups in the Visible Screen Section

This time we focus on how to align nodes and groups vertically in the visible screen section by using the method ScrollToNodeLine(…) of the VcGantt object of VARCHART XGantt.

The method ScrollToNodeLine(…) has two parameters. The first one specifies the node to which the screen section is to be aligned, and the second one defines a reference point of the node according to which the visible section aligns. The below pictures show the alignments of three different reference points of node "50":


vcTopAligned




vcGantt1.ScrollToNodeLine(vcGantt1.GetNodeByID("50"),
VcVerticalAlignment.vcTopAligned);


vcVerCenterAligned



vcGantt1.ScrollToNodeLine(vcGantt1.GetNodeByID("50"), VcVerticalAlignment.vcVerCenterAligned);


vcBottomAligned



vcGantt1.ScrollToNodeLine(vcGantt1.GetNodeByID("50"),
VcVerticalAlignment.vcBottomAligned);

It is a bit more difficult to align the screen section according to a group, since ScrollToNodeLine(...) only accepts an object of the type VcNode.

This is the trick to align groups: Retrieve the first node of the desired goup and temporarily modify the order of the nodes by putting them all in a single row. Before doing so, switch off the line optimization to keep performance at its optimum.

Then invoke the method ScrollToNodeLine(…) and put the node order back to its original state. The twofold change of order will remain unnoticed on the screen:


VB Sample Code

Dim group As VcGroup
Dim node As VcNode
Dim arrangedInOneRowStatus As Boolean
Dim optimizedStatus As Boolean

group = VcGantt1.GroupCollection.GroupByName("Group 5")
node = group.NodeCollection.FirstNode()

arrangedInOneRowStatus = group.NodesArrangedInOneRow
optimizedState = group.NodesOptimized

If group.NodesArrangedInOneRow = False Then
   group.NodesOptimized = False
End If

group.NodesArrangedInOneRow = True
VcGantt1.ScrollToNodeLine(node, VcVerticalAlignment.vcTopAligned)
group.NodesArrangedInOneRow = arrangedInOneRowStatus
group.NodesOptimized = optimizedState


C# Sample Code

VcGroup group = vcGantt1.GroupCollection.GroupByName("Group 5");
VcNode node = group.NodeCollection.FirstNode();

bool arrangedInOneRowStatus = group.NodesArrangedInOneRow;
bool optimizedState = group.NodesOptimized;

if (group.NodesArrangedInOneRow == false)
   group.NodesOptimized = false;

group.NodesArrangedInOneRow = true;
vcGantt1.ScrollToNodeLine(node,VcVerticalAlignment.vcTopAligned);
group.NodesArrangedInOneRow = arrangedInOneRowStatus;
group.NodesOptimized = optimizedState;