Articles in this section
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

                           

Hide controls dynamicall in ToolStripEx with image

Figure 1. Hide controls dynamically in ToolStripEx with image.

Show controls dynamicall in ToolStripEx with image

Figure 2. Show controls dynamically in ToolStripEx with image.

Samples:

C#: How to hide and show ToolStripEx items dynamically?

VB: How to hide and show ToolStripEx items dynamically?

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