Controls Size property

    Date: 09/21/05 (C Sharp)    Keywords: no keywords

    Hi guys,

    here is another freaky thing that kind of bugs a lot. Maybe someone has ideas to this. We have a sort of a "dynamic" interface builder that will take a control schema and place the controls into a TableLayoutPanel control with pre-created rows and columns. All row and columns styles are set to AutorSize SizeType.

    What happens is even though the TableLayoutPanel AutoSize property is set to true and its AutoSizeMode to GrowAndShrink, it will not grow enough to show the full control inside a cell.

    The whole thing looks bit messy: a Panel with a couple of cells with TabbedControl, then TableLayoutPanel inside of it with a few GroupBox controls that will contain TableLayoutPanels as well.

    What I tried to do is this bit of code:

    protected void setSize(Control ctrl)
      {
       if (!ctrl.Created)
       {
        ctrl.CreateControl();
       }
       foreach(Control cc in ctrl.Controls)
       {
        if (!cc.Created)
        {
         cc.CreateControl();
        }
        if (cc.Controls.Count > 0)
        {
         cc.AutoSize = false;
         cc.Size = cc.PreferredSize;
        }
        setSize(cc);
       }
      }

    A simple recursion that will run through all the controls all try to set their Size property to equal PrefferedSize property.

    The funny thing, again, is that once this is executed:

    cc.Size = cc.PreferredSize;

    the Size will not change to equal the PrefferedSize property.

    How can this be possible? Can it be something like the parent control sort of "holding" the children size and change it back once it was changed somewhere?

    Please advide, I am about to run into a wall and nock myself out.

    Source: http://www.livejournal.com/community/csharp/35393.html

« System.Diagnostics.Trace || Forms Authentication problems »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home