开发者

Create Autosizeble panel with panels inside

开发者 https://www.devze.com 2023-01-02 20:22 出处:网络
Sorry 开发者_如何转开发for not very clear question title, but maybe image will help to describe my ploblem:

Sorry 开发者_如何转开发for not very clear question title, but maybe image will help to describe my ploblem:

image http://my.jetscreenshot.com/2951/20100604-ioyo-164kb.jpg

I want small child panels in parent panel to be autosizeable. Here is my markup and codebehind:

    protected void Page_Load(object sender, EventArgs e)
        {
            var bkg = new[] { "background-color: wheat;", "background-color: gray;", "background-color: #AAAAAA;" };
            var random = new Random();
            for (var i = 0; i < 285; i++)
            {
                var panel = new Panel
                                {
                                    Header = false,
                                    Width = 60,
                                    Height = 30,
                                    BodyStyle = bkg[random.Next(0, 3)],
                                    Frame = false,
                                    StyleSpec = "padding-top: 1px; padding-left: 1px;",
                                    ID = "panel_" + i,
                                    Html = string.Format("<span class='x-unselectable'>{0}</span>", i)
                                };
                var cell = new Cell();
                cell.Items.Add(panel);
                TableLayout1.Cells.Add(cell);
            }

        }

<ext:Panel ID="pnlWorkArea" runat="server" Title="Test">
    <Body>
        <ext:TableLayout ID="TableLayout1" runat="server" Columns="15">
        </ext:TableLayout>
    </Body>
</ext:Panel>


If you mean that you want the child panel arrangement to completely fill the center region, there's not a simple way to do that other than calculating the inner dimensions of the region, then assigning fixed height/width to the child panels as you are now, but based on your measurements. You could do this either by handling the render event or overriding onRender of the center region panel.

If the number of rows and columns is always the same you could try using % dimenstions, but in my experience that does not work consistently across browsers (you can get small gaps sometimes due to rounding from decimal percentages to pixels).

0

精彩评论

暂无评论...
验证码 换一张
取 消