Hello Hendra,
You must be missing something in the code example. By using your sample data, you can COPY/PASTE the following code:
Imports Nevron.GraphicsCore
Imports Nevron.Diagram
Imports Nevron.Diagram.Shapes
Imports Nevron.Diagram.WinForm
Imports Nevron.Diagram.Layout
Imports Nevron.Diagram.DataImport
Imports System.Data.OleDb
...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' begin view init
DrawingView.BeginInit()
' display the document in the view
DrawingView.Document = DrawingDocument
' configure the view
DrawingView.ViewLayout = ViewLayout.Fit
DrawingView.Grid.Visible = False
DrawingView.GlobalVisibility.ShowPorts = False
DrawingView.HorizontalRuler.Visible = False
DrawingView.VerticalRuler.Visible = False
' create two stylesheets - one for the vertices and one for the edges
Dim vertexStyleSheet As New NStyleSheet()
vertexStyleSheet.Name = "Vertices"
DrawingDocument.StyleSheets.AddChild(vertexStyleSheet)
Dim edgeStyleSheet As New NStyleSheet()
edgeStyleSheet.Name = "Edges"
edgeStyleSheet.Style.StartArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Circle, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))
edgeStyleSheet.Style.EndArrowheadStyle = New NArrowheadStyle(ArrowheadShape.Arrow, "", New NSizeL(5, 5), New NColorFillStyle(Color.Gray), New NStrokeStyle(1, Color.Black))
DrawingDocument.StyleSheets.AddChild(edgeStyleSheet)
' configure the graph data source importer
Dim GraphImporter As New NGraphDataSourceImporter()
' set the document in the active layer of which the shapes will be imported
GraphImporter.Document = DrawingDocument
' set the connection string, data sources and DataAdapters
' in this example we have created two OleDbDataAdapters:
' the PagesDataAdapter selects all records and columns from the Pages table of the SiteMap.mdb
' the LinksDataAdapter selects all records and columns from the Links table of the SiteMap.mdb
Dim connString As String = "Data Source=""" + Application.StartupPath + "\SiteMap.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";"
Dim PagesDataAdapter As New OleDbDataAdapter("SELECT * FROM Pages", connString)
Dim LinksDataAdapter As New OleDbDataAdapter("SELECT * FROM Links", connString)
GraphImporter.VertexDataSource = PagesDataAdapter
GraphImporter.EdgeDataSource = LinksDataAdapter
' vertex records are uniquely identified by their Id (in the Pages table)
' edges link the vertices with the FromPageId and ToPageId (in the Links table)
GraphImporter.VertexIdColumnName = "Id"
GraphImporter.FromVertexIdColumnName = "FromPageId"
GraphImporter.ToVertexIdColumnName = "ToPageId"
' create vertices as rectangles shapes, with default size (60, 30)
Dim shapesFactory As New NBasicShapesFactory()
shapesFactory.DefaultSize = New NSizeF(60, 30)
GraphImporter.VertexShapesFactory = shapesFactory
GraphImporter.VertexShapesName = BasicShapes.Rectangle.ToString()
' set stylesheets to be applied to imported vertices and edges
GraphImporter.VertexStyleSheetName = "Vertices"
GraphImporter.EdgeStyleSheetName = "Edges"
' use layered graph layout
Dim layout As New NLayeredGraphLayout()
layout.Direction = LayoutDirection.TopToBottom
layout.LayerAlignment = RelativeAlignment.Near
GraphImporter.Layout = layout
' subscribe for the vertex imported event,
' which is raised when a shape was created for a data source record
AddHandler GraphImporter.VertexImported, AddressOf OnVertexImported
' import
GraphImporter.Import()
' end view init
DrawingView.EndInit()
End Sub
Private Sub OnVertexImported(ByVal dataSourceImporter As NDataSourceImporter, ByVal shape As NShape, ByVal record As INDataRecord)
' display the page title in the shape
Dim text As Object = record.GetColumnValue("Title")
If text Is Nothing Then
shape.Text = "Title not specified"
Else
shape.Text = text.ToString()
End If
shape.SizeToText(New NMarginsF(10))
End Sub
Following is the generated diagram:
Best Regards,
Nevron Support Team