I have a ribbon that I would like to disable baritems that don't have events assigned.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Michael,
I'm afraid there is no easy way to implement this functionality. You need to use the reflection mechanism, and disable bar items in the same way you disable any other control; for example, the standard MS button. The implementation of this functionality doesn't concern our controls. If you're able to implement this functionality for the button, please provide me the code, and I help you to implement it for bar items.
Thanks,
Marina
All I really need to know is How do I test BarButtonItem1 has a Itemclick event assigned.
Michael,
As I said above, there is no easy way to implement this functionality. .Net doesn't provide this feature directly for any control. Currently, I am investigating this opportunity and provide you an answer as soon as possible.
Thanks,
Marina
Hello,
You can check whether a BarButtonItem is subscribed to the ItemClick using the following code:
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles simpleButton1.Click Dim itemClickInfo As FieldInfo = GetType(BarItem).GetField("itemClick", BindingFlags.Static Or BindingFlags.NonPublic) Dim eventsInfo As FieldInfo = GetType(Component).GetField("events", BindingFlags.Instance Or BindingFlags.NonPublic) Dim itemClick As Object = itemClickInfo.GetValue(barButtonItem1) Dim Events As EventHandlerList = TryCast(eventsInfo.GetValue(barButtonItem1), EventHandlerList) If Not Events Is Nothing Then Dim handler As ItemClickEventHandler = TryCast(Events(itemClick), ItemClickEventHandler) If Not handler Is Nothing Then MessageBox.Show("The barButtonItem1 object is subscribed to the ItemClick event!") End If End If End Sub
Thanks,
Marina