I am removing some buttons from the form UI and replacing them with panels on an UltraStatusBar. I have set the panels Style = Button.
For the Windows command buttons, I currently use
Private Sub cmdAdd_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.EnabledChanged ' add code here.End Sub
How do I get the same functionality with the button-style panels?
TIA,
Dave
Hi David,
Since the user cannot enable or disable a button, you must be doing it in code. So you probably don't really need an event to tell you when the buttons are enabled or disabled - you could call the same code from wherever you are enabling and disabling the buttons. That's probably the easiest thing to do.
Of course, that might not always be the case. The buttons might be getting disabled as a result of some other code that you don't have access to. There's no specific event for the enabling and disabling of a button on a status bar, though. So what you would have to do is trap the PropertyChanged event. This is a pretty generic event that fires for any property change, so it requires a bit of code to determine what changed. I think you could do something like this:
private void ultraStatusBar1_PropertyChanged(object sender, Infragistics.Win.PropertyChangedEventArgs e) { PropChangeInfo propChangeInfo = e.ChangeInfo.FindPropId(StatusBarPropertyIds.Enabled); if (propChangeInfo != null) { UltraStatusPanel panel = propChangeInfo.Source as UltraStatusPanel; if (panel != null && panel.Style == PanelStyle.Button) { // The enabled state of a button changed. } } }
Thanks Mike,
The code sample works fine. Since the buttons are being enabled/disabled in code, it would be a minor maintenace issue to remember to call a routine every time that the Enabled state changed. Trapping the PropertyChanged event is a better solution for me in this case. In VB, the code is:
Private Sub myStatusBar_PropertyChanged(ByVal sender As System.Object, ByVal e As Infragistics.Win.PropertyChangedEventArgs) Handles myStatusBar.PropertyChanged Dim propChangeInfo As Infragistics.Shared.PropChangeInfo propChangeInfo = e.ChangeInfo.FindPropId(StatusBarPropertyIds.Enabled) If propChangeInfo IsNot Nothing Then Dim panel As UltraStatusPanel = TryCast(propChangeInfo.Source, UltraStatusPanel) If panel IsNot Nothing AndAlso panel.Style = PanelStyle.Button Then Dim isEnabled As Boolean = panel.Enabled ' do stuff. End If End IfEnd Sub
Thanks again!