Category / Section
How to hide and show ToolStripEx items dynamically in WinForms ToggleButton?
1 min read
Hide or show the ToolStripEx items
In ToolStripEx, its items appearance can be customized by using its property named Visible.
C#
if(this.toggleButton1.ToggleState == Syncfusion.Windows.Forms.Tools.ToggleButtonState.Active) { foreach (ToolStripItem button in this.toolStripEx1.Items) { // To hide the controls loaded in ToolStripEx button.Visible = false; this.toolStripEx1.Refresh(); } } else { foreach (ToolStripItem button in this.toolStripEx1.Items) { // To show the controls loaded in ToolStripEx button.Visible = true; this.toolStripEx1.Refresh(); } }
VB
Private Sub toggleButton1_ToggleStateChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.ToggleStateChangedEventArgs) Handles toggleButton1.ToggleStateChanged If Me.toggleButton1.ToggleState = Syncfusion.Windows.Forms.Tools.ToggleButtonState.Active Then For Each button As ToolStripItem In Me.toolStripEx1.Items 'To hide the control in ToolStripEx button.Visible = False Me.toolStripEx1.Refresh() Next button Else For Each button As ToolStripItem In Me.toolStripEx1.Items button.Visible = True 'To show the control in ToolStripEx Me.toolStripEx1.Refresh() Next button End If End Sub
Figure 1. Hide controls dynamically in ToolStripEx with image.
Figure 2. Show controls dynamically in ToolStripEx with image.
Samples: