Articles in this section
Category / Section

Changing the color of the LineConnector in WinForms Diagram

1 min read

Change lineConnector color

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

Please refer to the following code snippet in the 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)



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