# Unbound FlexDiagram

## Content

<span id="a6fde4d7-0d95-40a1-bf1d-0403e5fb4907" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="a6fde4d7-0d95-40a1-bf1d-0403e5fb4907" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">An unbound diagram in FlexDiagram is created programmatically without data binding. You can define and add each node and edge along with their properties and relationships. This method enables full control over layout and appearance, making it suitable for simple static diagrams or custom flowcharts with precise configurations.</span>
![](https://cdn.mescius.io/document-site-files/images/ba3667c3-8434-4d44-931a-224dda3ad70f/unbounddiagram.e37505.png?width=600)

### **<span id="4a67bf5c-fb14-46a0-bd37-82920d3fba74" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="4a67bf5c-fb14-46a0-bd37-82920d3fba74" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Create Unbound</span> Flex<span id="4a67bf5c-fb14-46a0-bd37-82920d3fba74" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="4a67bf5c-fb14-46a0-bd37-82920d3fba74" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Diagram</span>** 

1. <span id="cb07ee19-14ea-4aeb-98a5-67cc703fedf1" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="cb07ee19-14ea-4aeb-98a5-67cc703fedf1" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Create individual nodes and set their properties.</span>

```csharp
var startNode = new Node() { Text = "Start Process" };
var processNode = new Node() { Text = "Execute", Shape = Shape.RoundedRectangle };
var endNode = new Node() { Text = "Complete" };
```

2. <span id="ae86f535-a724-4d39-bdca-2c6abc41cfc9" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="ae86f535-a724-4d39-bdca-2c6abc41cfc9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Add the nodes to the diagram.</span>

```csharp
diagram.Nodes.Add(startNode);
diagram.Nodes.Add(processNode);
diagram.Nodes.Add(endNode);
```

3. <span id="266f1c41-f56e-4e6f-8f13-8dfbb83fdb20" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="266f1c41-f56e-4e6f-8f13-8dfbb83fdb20" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Create edges to define the connections between nodes.</span>

```csharp
diagram.Edges.Add(new Edge()
{
    Source = startNode,
    Target = processNode,
    TargetArrow = ArrowStyle.Normal
});
```

4. <span id="ce068f75-0835-48b8-ae1a-8f3ad71f17ef" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="ce068f75-0835-48b8-ae1a-8f3ad71f17ef" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Set the layout direction (optional).</span>

```csharp
// Set the direction of the diagram
diagram.Direction = DiagramDirection.TopBottom; // or LeftRight, RightLeft, BottomTopData-Bound Diagrams (Hierarchical Data)
```

#### **<span id="0af5ac8e-983f-467e-83d4-f6f657c2d7c9" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="0af5ac8e-983f-467e-83d4-f6f657c2d7c9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Unbound FlexDiagram Sample</span>**

```csharp
using C1.Chart;
using C1.Diagram;
using C1.Diagram.Parser;
using C1.Win.Diagram;

namespace FlexDiagramPoC
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            InitializeDiagram();
        }

        private void InitializeDiagram()
        {
            // Create FlexDiagram instance
            var diagram = new FlexDiagram();
            diagram.Dock = DockStyle.Fill;
            this.Controls.Add(diagram);

            diagram.Direction = DiagramDirection.TopBottom;

            // Create nodes
            var startNode = new Node() { Text = "Start Process" };
            var processNode = new Node() { Text = "Execute", Shape = Shape.RoundedRectangle };
            var endNode = new Node() { Text = "Complete" };

            // Add nodes to the diagram
            diagram.Nodes.Add(startNode);
            diagram.Nodes.Add(processNode);
            diagram.Nodes.Add(endNode);

            // Create and add edges (links)
            diagram.Edges.Add(new Edge()
            {
                Source = startNode,
                Target = processNode,
                TargetArrow = ArrowStyle.Normal
            });

            diagram.Edges.Add(new Edge()
            {
                Source = processNode,
                Target = endNode,
                TargetArrow = ArrowStyle.Normal
            });
        }
    }
}
```