The ExOrgChart component permits the totally automatic generation of organigrams. An organigram generally provides a clear picture of the hierarchical position of the various actors. The ExOrgChart control shows a hierarchical display of nodes, each one having an HTML caption, pictures and icons aligned to any side of the node.
The ZoomWidth property specifies a value indicating how large the chart will appear on horizontal axis.
The ZoomWidthMode property specifies a value that indicates whether the ZoomWidth property is updated when the control is resized.
The following sample resizes the chart to fit the client's area:
With ChartView1
.BeginUpdate
.ZoomWidthMode = exControlSize
.ZoomHeightMode = exControlSize
.EndUpdate
End With
The Nodes.Add method inserts a node to the chart.
For instance, using ADO, you can load a hierarchical table, if your
table contains a field that identifies the key of the record ( "EmployeeID"
), and a field that holds the key to the parent record ( "ReportsTo"
), like in the following sample:
Option Explicit
Private Sub Form_Load()
Dim i As Long
Dim rs As Object, t As IPictureDisp
Set rs = CreateObject("ADODB.Recordset")
rs.Open "Select * From Employees", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\sample.mdb", _
3
With ChartView1
.BeginUpdate
While Not rs.EOF()
With .Nodes
With .Add(getInfo(rs), rs("ReportsTo").Value, rs("EmployeeID").Value)
.ToolTip = rs("Notes") + "<br><upline><dotline><r><b>" + _
rs("FirstName") + " " + rs("LastName") + "<b>"
End With
End With
rs.MoveNext
Wend
.EndUpdate
End With
Exit Sub
End Sub
Private Function getInfo(ByVal r As Object) As String
getInfo = r("TitleOfCourtesy") + " <b><fgcolor=000080>" + r("FirstName") + _
" " + r("LastName") + "</fgcolor></b><br>" + _
r("Title") + "<br><upline><dotline>" + _
r("City") + "<br> " + r("Address")
End Function
Yes, the Exontrol ExPrint component ( exprint.dll ) provides Print
and Print Preview capabilities for the exOrgChart component. Once that
you can have the exPrint component in your Components list, insert a new
instance of "ExPrint 1.0 Control Library" to your form and add
the following code:
Private Sub Command1_Click()
With Print1
Set .PrintExt = ChartView1.Object
.Preview
End With
End Sub
The Exontrol Print Preview mainframe looks like follows:
The exPrint component is free of charge, if you are
registered user of the exOrgChart component.
The following VB sample opens the Print Preview frame:
With Print1
Set .PrintExt = ChartView1.Object
.Preview
End With
The following C++ sample opens the Print Preview frame:
Yes. The exOrgChart component provides WYSWYG
Template/Layout Editor that helps you to initialize the control at
design mode. In design mode, select 'Properties' item from object's
context menu. A template file is a collection of instructions that
control loads at runtime. In other words the template file holds a
collection of properties and their values, methods and objects, into a
TEXT file. The template file combines XML style with something close to
VBScript. We call it X-Script. It is important to specify that the
editor and the X-Script DO NOT USE any external VB script engine, Active
script engine, XML parser or DOM. The X-Script was implemented from
scratch as lite as possible to let users customize the control in design
mode no matter what programming languages they are using. The template
files are the same for any programming language, and do the same thing
for all! For instance, you can copy and paste the template file from a
VFP control to a C++ control! The editor automatically updates the
control's look and feel while you are editing the template file. This
way you can learn easy how a property or a method reacts! Also, the
editor provides a type library context menu that helps you to find
quickly a property ( CTRL + SPACE invokes it )
The following template loads nodes at design mode:
BeginUpdate
Root
{
ForeColor = RGB(0,0,255)
BackColor = RGB(255,255,0)
Caption = "<r><dotline><b>CObject</b><br>CObject is the principal base class for the Microsoft Foundation Class Library.<br><upline><dotline>Methods:<r>4"
Image = 1
}
Nodes
{
Add("<r><dotline><b>CCmdTarget</b><br>CCmdTarget is the base class for the Microsoft Foundation Class Library message-map architecture.<br><upline><dotline>Methods:<r>14",,"target")
{
ForeColor = RGB(0,0,255)
BackColor = RGB(255,255,0)
}
Add("<r><dotline><b>CWnd</b><br>This class provides the base functionality for all window classes in MFC.<br><upline><dotline>Methods:<r>18","target","wnd")
Add("<r><dotline><b>CControlBar</b><br>CControlBar is the base class for the control-bar classes CStatusBar, CToolBar, CDialogBar, CReBar, and COleResizeBar.<br><upline><dotline>Methods:<r>18","wnd","cb")
Add("<r><dotline><b>CDialogBar</b><br>The CDialogBar class provides the functionality of a Windows modeless dialog box in a control bar.<br><upline><dotline>Methods:<r>18","cb","db")
Add("<r><dotline><b>CDialog</b><br>This class provides the base functionality for all dialog classes in MFC.<br><upline><dotline>Methods:<r>18","wnd","dialog")
Add("<r><dotline>Exceptions<br>Exceptions occur when a program executes abnormally because of conditions outside the program's control.",,"exceptions")
Add("<r><dotline>Graphichal Drawing Objects<br>Windows provides a variety of drawing tools to use in device contexts.",,"gdi") .Width = 255
Add("<r><dotline>Syncronization<br>Classes that use arrays can also implement their own synchronization using the SyncRoot property..",,"sync")
}
EndUpdate
The user can copy the control's content to the
clipboard by pressing the CTRL + C key. For instance, if you want to
include the control's content to a Microsoft Word document, you have to
copy the control's content and paste it in the document. Use the Copy
method to programmatically copy the control's content to the cliboard.
By default, the control provides properties like BorderWidth
property and BorderHeight
property to specify the size of the borders inside the control's client
area. Please make sure that BorderWidth property is not 0. If it is 0 it
is possible that the link between the nodes and their parent to be
hidden depending on the nodes content.
By default, the control's Root
has no key associated. Thought you can add a new node as child of the
root object and to use the ExplorerFromNode
property to assign a new displayed root. The following sample displays a
new root for your control:
Private Sub Form_Load()
With ChartView1
.Nodes.Add "NewRoot", , "newRoot"
.ExploreFromNode = "newRoot"
.Nodes.Add "Child 1", "newRoot", "child_1"
.Nodes.Add "Child 2", "newRoot", "child_2"
End With
End Sub
Also, you can use the Key property to
change the node's key.
The Node object provides a property
ArrangeSiblingNodesAs that helps you to specify how the child nodes are
arranged on the page. By default, the control arranges vertically the
child nodes.
The control provides the SaveXML
method that saves the control's data to XML document. Use the LoadXML
method to load XML documents saved using the SaveXML method. The SaveXML
method may save data to a file , an XML document object, or a custom
object that supports persistence like described here:
String - Specifies the file name. Note that this must be a file
name, rather than a URL. The file is created if necessary and the
contents are entirely replaced with the contents of the saved
document. For example:
G2antt1.SaveXML("sample.xml")
XML Document Object. For example:
Dim xmldoc as Object
Set xmldoc = CreateObject("MSXML.DOMDocument")
G2antt1.SaveXML(xmldoc)
Custom object supporting persistence - Any other
custom COM object that supports QueryInterface for IStream,
IPersistStream, or IPersistStreamInit can also be
provided here and the document will be saved accordingly. In the IStream
case, the IStream::Write method will be called as it saves
the document; in the IPersistStream case, IPersistStream::Load
will be called with an IStream that supports the Read,
Seek, and Stat methods
Use the <a> anchor element in Caption
property of the Node,
or when inserting a node using the Add
method. The control fires the AnchorClick
event when the user clicks an anchor element. Use the ShowToolTip
property to programmatically show a tooltip for specified anchor
element.
Use the ArrangeSiblingNodesAs
property on exTree, and so the child nodes are arranged as a tree, each
child nodes is indented relative to the parent node.
The exception may occurs if not using the RuntimeKey
as explained in the redist.txt file that was provided to you at the time
you received the registration e-mail.
Here's the snippet of code you need to add to your code/sample:
VB.NET
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
exontrol.EXORGCHARTLib.exorgchart.RuntimeKey = "your runtime license key"
End Sub
C#
public Form1()
{
exontrol.EXORGCHARTLib.chartview.RuntimeKey = "your runtime license key";
InitializeComponent();
}
or
private void Form1_Load(object sender, EventArgs e)
{
exontrol.EXORGCHARTLib.chartview.RuntimeKey = "your runtime license key";
}
Where the "your runtime license key" can be found on your
registration e-mail. This is related to the "stop working
after" note.
You need to store the node from cursor using NodeFromPoint property during LayoutStartChanging event and update the node's new Parent property in LayoutEndChanging
event as shown in the following VB sample:
Private sNode As EXORGCHARTLibCtl.Node
Private Sub ChartView1_LayoutStartChanging(ByVal Operation As EXORGCHARTLibCtl.LayoutChangingEnum)
If (Operation = exMoveNode) Then
Set sNode = ChartView1.NodeFromPoint(-1, -1)
End If
End Sub
Private Sub ChartView1_LayoutEndChanging(ByVal Operation As EXORGCHARTLibCtl.LayoutChangingEnum)
If (Operation = exMoveNode) Then
If Not (sNode Is Nothing) Then
Debug.Print "The current node moved to " & sNode.Parent.Caption
End If
Set sNode = Nothing
End If
End Sub
The LayoutEndChanging(exMoveNode) event notifies your application
once the user ends the moving operation/drop event.
The Exontrol ExPrint component ( exprint.dll ) provides Print and Print
Preview capabilities for the Exontrol ExOrgChart component.
The requirements for the FitToPage option:
Exontrol.ExPrint version 5.2 ( or greater )
Exontrol.ExOrgChart version 7.1 ( or greater )
The FitToPage option could be one of the following:
On, (Fit-To-Page) the control's content is printed to a single page
( version 6.1 )
p%, (Adjust-To) where p is a positive number that indicates the
percent from normal size to adjust to. For instance, the "FitToPage =
50%" adjusts the control's content to 50% from normal size. ( version
8.1 )
w x, (Fit-To Wide) where w is a positive number that indicates that the control's content fits w pages wide by
how many pages tall are required. For instance,
"FitToPage = 3 x" fits the control's content to 3 pages wide by
how many pages tall is are required. ( version
8.1 )
x t, (Fit-To Tall) where t is a positive number that specifies
that the control's content fits t pages tall by how many pages wide are
required. For instance,
"FitToPage = x 2" fits the control's content to 2 pages tall by
how many pages wide are required. ( version
8.1 )
w x t, (Fit-To) where w and t are positive numbers that specifies
that the control's content fits w pages wide by t pages tall. For instance,
"FitToPage = 3 x 2" fits the control's content to 3 pages wide by
2 pages tall. ( version
8.1 )
The following VB6 sample shows how to show the eXList/COM's content to one page
when print or print preview the component:
Private Sub Command1_Click()
With Print1
.Options = "FitToPage = On"
Set .PrintExt = ChartView1.Object
.Preview
End With
End Sub
The following VB/NET sample shows how to show the eXList/NET's content to one page
when print or print preview the component:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With Exprint1
.Options = "FitToPage = On"
.PrintExt = ExchartView1
.Preview()
End With
End Sub
The Parent property of the Node returns the node's parent if exists or nothing
if the node is the root object or has no parent. The following sample uses the
Parent property to calculate the node's level/
Private Function Level(ByVal n As EXORGCHARTLibCtl.Node) As Integer
Dim nLevel As Integer
While Not n Is Nothing
nLevel = nLevel + 1
Set n = n.Parent
Wend
Level = nLevel
End Function