2

パネルコントロールがあります。パネルにはさらに多くのコントロールがあります。パネルのドックプロパティを「塗りつぶし」に設定しました。パネルは画面の解像度に基づいてサイズ変更されます。ただし、コントロールは同じままです。パネルのコントロールは、画面ソリューションに基づいてサイズ変更されません。

同じページにさらに多くのラベルとパネル、テキストボックスとボタンがあります。

画面の解像度に基づいてページ内のすべてのコントロールのサイズを変更するようにdockプロパティを設定するにはどうすればよいですか?

助けてくれてありがとう

4

3 に答える 3

1

クライアント側で画面解像度が変更されたときに、このソリューション (ここから描画) がフォーム内のすべてのコントロールを表示するのに役立つことを願っています。

int i_StandardHeight = 768;//Developer Desktop Height Where the Form is Designed
                int i_StandardWidth = 1024; ;//Developer Desktop Width Where the Form is Designed
                int i_PresentHeight = Screen.PrimaryScreen.Bounds.Height;
                int i_PresentWidth = Screen.PrimaryScreen.Bounds.Width;
                float f_HeightRatio = new float();
                float f_WidthRatio = new float();
                f_HeightRatio = (float)((float)i_PresentHeight / (float)i_StandardHeight);
                f_WidthRatio = (float)((float)i_PresentWidth / (float)i_StandardWidth);
                foreach (Control c in this.Controls)
                {
                    if (c.GetType().ToString() == "System.Windows.Forms.Button")
                    {
                        Button obtn = (Button)c;
                        obtn.TextAlign = ContentAlignment.MiddleCenter;
                    }
                    if (c.HasChildren)
                    {
                        foreach (Control cChildren in c.Controls)
                        {
                            cChildren.SetBounds(Convert.ToInt32(cChildren.Bounds.X * f_WidthRatio), Convert.ToInt32(cChildren.Bounds.Y * f_WidthRatio), Convert.ToInt32(cChildren.Bounds.Width * f_WidthRatio), Convert.ToInt32(cChildren.Bounds.Height * f_HeightRatio));
                            //cChildren.Font = new Font(cChildren.Font.FontFamily, cChildren.Font.Size * f_HeightRatio, cChildren.Font.Style, cChildren.Font.Unit, ((byte)(0)));
                        }
                        c.SetBounds(Convert.ToInt32(c.Bounds.X * f_WidthRatio), Convert.ToInt32(c.Bounds.Y * f_WidthRatio), Convert.ToInt32(c.Bounds.Width * f_WidthRatio), Convert.ToInt32(c.Bounds.Height * f_HeightRatio));
                       // c.Font = new Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, ((byte)(0)));
                    }
                    else
                    {
                        c.SetBounds(Convert.ToInt32(c.Bounds.X * f_WidthRatio), Convert.ToInt32(c.Bounds.Y * f_WidthRatio), Convert.ToInt32(c.Bounds.Width * f_WidthRatio), Convert.ToInt32(c.Bounds.Height * f_HeightRatio));
                       // c.Font = new Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, ((byte)(0)));
                    }
                }
                this.Height = Convert.ToInt32(i_StandardHeight * f_HeightRatio);
                this.Width = Convert.ToInt32(i_StandardWidth * f_WidthRatio); 
于 2013-02-18T09:59:58.293 に答える
1

プロパティを使用してAnchor、コントロールを 4 つの側面すべてに固定します。

于 2010-05-10T10:55:24.447 に答える
0

コンテナー Panel の Dock プロパティを設定するだけでなく、Panel 内のコントロールの Anchor または Dock プロパティも設定する必要があります。通常、フォームに複数のコントロールがある場合は、TableLayoutPanel、FlowLayoutPanel、または別の Panel を追加すると役立ちます。

于 2010-05-10T13:22:57.147 に答える