Ticket T291233
Visible to All Users

AccordionControl - How to prevent an element from being expanded

created 9 years ago

hello,

how do I delay the expand of an element in the OnClick event? I mean, for example, to expand only if the Content Container has a special control inside, or something like this. The main idea is to "tell" the element not to expand.

Is there a way to do that?

Thank you

Comments (2)
Nadezhda (DevExpress Support) 9 years ago

    Hello Tudor,

    As far as I understand, you wish to prevent expanding AccordionControlElement. If so, you can set the AccordionControlElement.Enable  property to false.
    Here is a code snippet that illustrates this approach:

    C#
    protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); var hitInfo = this.CalcHitInfo(e.Location); hitInfo.ItemInfo.Element.Enabled = false; }

    Try this approach and let us know if it works for you.
    I hope to hear from you soon.

      yes, this is an approach. but, I think that I was not quite clear.
      I want the AccordionElement to be Enabled because I will have am UserControl in HeaderControl which will consist in a collection of buttons, and as far as I see, if the Element is disabled the HeaderControl will be disabled also, and I don't want this.
      My scenario is like this: whent the ContentContainer of Element1 has something special inside, I want the Element1 NOT TO EXPAND and the buttons in the HeaderControl to be functional(click-able). I hope I am now more clear… or not?! :)

      Answers approved by DevExpress Support

      created 9 years ago

      Hello,
      Thank you for the clarification.
      Starting with 15.1.7, we have introduced a new option to the AccordionControl.ElementClick event handler args. Enable the e.Handled option to prevent a group from being expanded. If you disable the AccordionControl.ExpandGroupOnHeaderClick option, the group can be expanded/collapsed only by clicking the expand button. To determine whether a click was performed over this button, calculate the HitInfo object:

      C#
      void accordionControl1_ElementClick(object sender, ElementClickEventArgs e) { AccordionControlHitInfo hi = accordionControl1.CalcHitInfo(accordionControl1.PointToClient(MousePosition)); if (hi.HitTest == AccordionControlHitTest.Button) e.Handled = e.Element == accordionControlElement2; }

      In general, the same task could be done by handling the AccordionControl.ExpandStateChanging event and clearing the e.ElementsToExpandCollapse collection. However, I've noticed that it doesn't prevent the e.Element group from expansion. I've passed this issue to our R&D team for further research - AccordionControl - Clearing the e.ElementsToExpandCollapse collection in the ExpandStateChanging event handler doesn't prevent e.Element from being expanded. We will update that ticket once we make any progress.

        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.