Menu

#1 Issues on Nesting Accordion

1.0
closed
None
2015-08-03
2015-07-14
No

I am facing issue when nesting accordion inside another accordion.

Issue: height and width of parent accordion is keep increasing on every checked changed event of parent accordion.

Discussion

  • Dr. Rajesh Kumar Rolen

    it got resolved resolved after commenting below comment
    c2.Margin = (cb.Checked ? c2.marginCached : Padding.Empty);

    please suggest

     
    • Opulos Inc.

      Opulos Inc. - 2015-07-14

      Possibly one of your controls is missing AutoSizeMode =
      AutoSizeMode.GrowAndShrink.
      Note: The default value of c2.marginCached is Padding.Empty. The value of
      marginCached is assigned in the Add(...) method.

      public CheckBox Add(Control c, String text, String toolTip = null, double
      fillWt = 0, bool? open = null, Padding? contentPadding = null, Padding?
      contentMargin = null
      , Color? contentBackColor = null, Padding?
      checkboxMargin = null) {
      ...
      c2.marginCached = Get(contentMargin, ContentMargin);

      If you disable that line, then expanding the checkbox will not increase the
      margin. For example, using a big margin like Padding(35), the expanded
      control should look like:

      Add(new TextBox(), "Parent1", contentMargin:new Padding(35));
      [image: Inline image 1]

      With the disabled line, it would look like:
      [image: Inline image 2]

      You should set a breakpoint at the line you commented out and verify that
      cachedMargin is not Padding.Empty. I suspect another control inside the
      accordion is incorrectly calculating its size, and it is set to not shrink.

      I have tried to reproduce the problem but cannot. I've attached some code I
      was playing around with to try to reproduce the problem. If you are able to
      reproduce the problem using a small example then let me know.

       

      Last edit: Opulos Inc. 2015-07-15
  • Opulos Inc.

    Opulos Inc. - 2015-07-15

    It looks like you want to use 'accordion.FillWidth = false'. Let me know if that solves your problem.

     
  • Dr. Rajesh Kumar Rolen

    I am using testing code provided by you.
    just modified it to make accordian dock fill in form.

    but i am facing issue is that nested according is showing scrollbar when i increase form's size and reduce it back.

    This happens even if i have made autosizemode to grow and shrink.
    even if nestedAccordion is blank, same issue..

    this happens only if nested accordion is visible on screen

    private void Form1_Load(object sender, EventArgs e)
    {
    List<CheckBox> checkboxList = new List<CheckBox>();

            Accordion accNested = new Accordion() { Dock = DockStyle.Fill };
            accNested.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            checkboxList.Add(accNested.Add(CreateControl(), "Child1"));
            checkboxList.Add(accNested.Add(CreateControl(), "Child2"));
    
            Padding? margin = new Padding(35);
    
            Form f = this;
            Accordion accParent = new Accordion() { BackColor = Color.Red };
            checkboxList.Add(accParent.Add(CreateControl(), "Parent1", contentMargin: margin));
            checkboxList.Add(accParent.Add(accNested, "Parent2"));
            //checkboxList.Add(accParent.Add(CreateControl(), "Parent2", contentMargin:margin));
            checkboxList.Add(accParent.Add(CreateControl(), "Parent3", contentMargin: margin));
            accParent.Dock = DockStyle.Fill;
            accParent.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            accParent.AutoSize = false;
            accParent.FillHeight = false;
            //accParent.Dock = DockStyle.Fill;
            //accParent.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            //accParent.AutoSize = true; // required for GetPreferredSize(...) to be called
    
            /*FlowLayoutPanel fp3 = new FlowLayoutPanel { FlowDirection = System.Windows.Forms.FlowDirection.TopDown };
            fp3.Margin = Padding.Empty;
            //fp3.AutoSize = true;
            fp3.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            fp3.BackColor = Color.LightBlue;
            fp3.Controls.Add(accParent);*/
    
            f.Controls.Add(accParent);
    
            foreach (CheckBox cb1 in checkboxList)
            {
                cb1.CheckedChanged += delegate
                {
    
                    //accParent.Size = accParent.PreferredSize;
                    Size s = accParent.PreferredSize;
                    //s.Width += 5;
                    accParent.Size = s;
                    //fp3.Size = s;
                };
            }
    
            Button btnUpdateSize = new Button { AutoSize = true, Text = "Update Size" };
            btnUpdateSize.Dock = DockStyle.Bottom;
            f.Controls.Add(btnUpdateSize);
            btnUpdateSize.Click += delegate
            {
                Size s = accParent.PreferredSize;
                accParent.Size = s;
            };
    
        }
        private static Control CreateControl(Control tb = null)
        {
            FlowLayoutPanel fp1 = new FlowLayoutPanel { FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight, Dock = DockStyle.Fill };
            fp1.AutoSizeMode = AutoSizeMode.GrowOnly;
            fp1.AutoSize = true;
            if (tb == null)
            {
                tb = new TextBox();
                //tb = new Button { Text = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", AutoSize = true, AutoSizeMode = AutoSizeMode.GrowOnly };
            }
    
            fp1.Controls.Add(tb);
            return fp1;
        }
    
     

    Last edit: Dr. Rajesh Kumar Rolen 2015-07-21
  • Dr. Rajesh Kumar Rolen

    Any one there to help me out ?

     
  • Opulos Inc.

    Opulos Inc. - 2015-07-22

    A solution is almost ready.

     
    • Dr. Rajesh Kumar Rolen

      Thanks a lot Opulos, i just want to check if someone is looking into it, as the control (accordion) is really good and i really love it but this issues was killing me, i tried a lot myself as well but was not able to find solution that is why i posted here..

      thanks

       
  • Opulos Inc.

    Opulos Inc. - 2015-07-23

    I thought I was close to a solution calculating the true available width by subtracting the aggregate margin and padding widths from the the a.ClientSize.Width in the FLP GetPreferredSize(...) method. However, in one case where an Accordion was added to a TableLayoutPanel and that panel was added as a child of another Accordion would need to be adjusted differently depending on the width of its CellBorderLayout property. Having to handle rules for specific controls does not make sense, which means a different approach is needed.

    At this point, I'm thinking of replacing the internal host FlowLayoutPanel (FLP) with a simple LayoutEngine specifically designed for the Accordion. This would also have the advantage of ditching the DummyControl, which is a crutch to make the FlowLayoutPanel work.

     
    • Dr. Rajesh Kumar Rolen

      Any good news on this ?

       
    • Dr. Rajesh Kumar Rolen

      I mean if it is done then please let me know, i am desparately looking for it.

       
  • Opulos Inc.

    Opulos Inc. - 2015-08-03

    Please try the version just released, v2015.08.03. It should solve your problem. This ticket is closing. If there are any other issues then please start a new ticket. Thanks for your feedback!

     
  • Opulos Inc.

    Opulos Inc. - 2015-08-03

    Closed-Fixed.

     
  • Opulos Inc.

    Opulos Inc. - 2015-08-03
    • status: open --> closed
    • discussion: enabled --> disabled