Ticket Q98251
Visible to All Users

How can I test if BarItem has click event associated with it and if doesn't disable the item

created 17 years ago

I have a ribbon that I would like to disable baritems that don't have events assigned.

Show previous comments (1)
MB MB
Michael Benowitz 17 years ago

    All I really need to know is How do I test BarButtonItem1 has a Itemclick event assigned.

    DevExpress Support Team 17 years ago

      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

      DevExpress Support Team 17 years ago

        Hello,
        You can check whether a BarButtonItem is subscribed to the ItemClick using the following code:

        Visual Basic
        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

        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.