How do I change the color of the LineConnector in WinForms Diagram?
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)''''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)
{
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
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!