Articles in this section
Category / Section

How do I set Diagram to ReadOnly state in WinForms Diagram?

2 mins read

How do I set the Diagram to a ReadOnly state, but still retain certain features like Zooming?

Diagram user interactivity is enabled through the interactive Tools registered with the Diagram's Controller. To disable interactivity, you will have to iterate through the list of Tools and selectively enable/disable each tool depending on the functionality that you want to retain. The following code shows how to disable all but the Zoom and Pan tools:

C#

// Get the collection of registered Tools, and disable those that are not required
Syncfusion.Windows.Forms.Diagram.Tool[] tools = this.diagramComponent.Controller.GetAllTools();
foreach (Tool tool in tools)
{
    // Retain the Enabled state for the Zoom and Pan tools
    if ((tool.Name == "ZoomTool") || (tool.Name == "PanTool"))
        continue;
    tool.Enabled = false;
}
this.diagramComponent.AllowDrop = false;

 

VB

Dim tools As Syncfusion.Windows.Forms.Diagram.Tool() = Me.diagramComponent.Controller.GetAllTools()
Dim tool As tool
For Each tool In tools
' Retain the Enabled state for the Zoom and Pan tools
If Not (tool.Name = "ZoomTool") And Not (tool.Name = "PanTool") Then
tool.Enabled = False
End If
Next
Me.diagramComponent.AllowDrop = False

 

Conclusion

I hope you enjoyed learning about how to set the Diagram to a ReadOnly state in WinForms Diagram.

You can refer to our  WinForms Diagram feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Diagram 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 Syncfusio, 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