How to have different color for the WinForms popupMenu when it is showing and reset to the default color when it is closed?
Handle the ParentBarItem event
This can be achieved by handling the ParentBarItem.Popup event. Please refer the bekow code snippet which illustrates this in WinForms PopupMenu:
C#
this.popupMenu1.ParentBarItem.Popup += new EventHandler(ParentBarItem_Popup); private void ParentBarItem_Popup(object sender, EventArgs e) { if(this.popupMenu1.IsShowing()) { MenuColors.MenuLeftStripColor = SystemColors.Control; MenuColors.MenuBGColor = SystemColors.Control; } else { // Reset to default color MenuColors.MenuLeftStripColor = Color.Empty; MenuColors.MenuBGColor = Color.Empty; } }
VB
AddHandler popupMenu1.ParentBarItem.Popup, AddressOf ParentBarItem_Popup Private Sub ParentBarItem_Popup(ByVal sender As Object,ByVal e As EventArgs) If Me.popupMenu1.IsShowing() Then MenuColors.MenuLeftStripColor = SystemColors.Control MenuColors.MenuBGColor = SystemColors.Control Else MenuColors.MenuLeftStripColor = Color.Empty MenuColors.MenuBGColor = Color.Empty End If
Sample: https://help.syncfusion.com/support/samples/kb/Tools.Windows/TColor/Color.zip
Conclusion
I hope you enjoyed learning about how to have different color for the WinForms popupMenu when it is showing and reset to the default color when it is closed.
You can refer to our WinForms Popup Menu’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Popup Menu documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms Popup Menu and other WinForms components.
If you have any queries or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!