Articles in this section
Category / Section

How do I change the color of the LineConnector in WinForms Diagram?

2 mins read

How do I change the color of the LineConnector when activating the line tool?

You can change the color of the LineConnector while activating the LineTool. You have to customize the LineTool and LineBase class. In the MouseUp event of the LineTool class, you can change the color of the link.

Please refer to the following code snippet in CustomLineConnector class.

public override Tool ProcessMouseUp(MouseEventArgs evtArgs)
{
    CompleteAction(ptStart, ptEnd);
}
private void CompleteAction(PointF ptStart, PointF ptEnd)
{
    Node node = CreateNode(ptStart, ptEnd);
    node.LineStyle.LineColor = Color.Red;
}

// To activate the LineTool in MainForm.cs
MyLineTool linetool = new MyLineTool(this.diagram1.Controller);
this.diagram1.Controller.RegisterTool(linetool);
this.diagram1.Controller.ActivateTool(linetool);

Public Overrides Function ProcessMouseUp(ByVal evtArgs As MouseEventArgs) As Tool
    CompleteAction(ptStart, ptEnd)
End Function
Private Sub CompleteAction(ByVal ptStart As PointF, ByVal ptEnd As PointF)
    Dim node As Node = CreateNode(ptStart, ptEnd)
    node.LineStyle.LineColor = Color.Red
End Sub

''''To activate the LineTool in MainForm.cs Dim linetool As MyLineTool = New MyLineTool(Me.diagram1.Controller) Me.diagram1.Controller.RegisterTool(linetool) Me.diagram1.Controller.ActivateTool(linetool)

Conclusion

I hope you enjoyed learning about how do I change the color of the LineConnector in WinForms Diagram.

You can refer to our WinForms Diagram feature tour page to learn about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied