Делаю на C# Windows Form приложение, вот не могу разобраться с резиновой вёрсткой, всё пока что так туго. 2 дня пытаюсь наладить. Сидебар (там тоже есть panel) слева имеет такие св-ва:
Anchor: Top, Left
Dock: None
Он не закреплён в родительском контейнере.
Сверху statusStrip:
Anchor: Top, Left
Dock: Top
Дальше у нас остаётся форма почты. под этой формой есть panel (тоже не закреплён в род контейнер):
Anchor: Top, Left
Dock: None
В другом классе то есть форме, это как отдельный компонент, при нажатии на сидебар открывается нужная страница. (работает если сидебар не закреплён, иначе не работает).
В чём проблема? Ролик на ютубе смотрел, не помогло вообще. Desinger.cs:
namespace CopterV8
{
partial class App
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.StatusStrip statusStrip;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(App));
this.Close = new System.Windows.Forms.ToolStripStatusLabel();
this.Networks = new System.Windows.Forms.ToolStripDropDownButton();
this.sidebar = new System.Windows.Forms.FlowLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.Menu = new System.Windows.Forms.Label();
this.menuButton = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.Home = new System.Windows.Forms.Button();
this.panel3 = new System.Windows.Forms.Panel();
this.Settings = new System.Windows.Forms.Button();
this.panel4 = new System.Windows.Forms.Panel();
this.Help = new System.Windows.Forms.Button();
this.panel5 = new System.Windows.Forms.Panel();
this.About = new System.Windows.Forms.Button();
this.panel6 = new System.Windows.Forms.Panel();
this.Software = new System.Windows.Forms.Button();
this.sidebarTimer = new System.Windows.Forms.Timer(this.components);
this.NotifyIconHi = new System.Windows.Forms.NotifyIcon(this.components);
this.Container = new System.Windows.Forms.Panel();
statusStrip = new System.Windows.Forms.StatusStrip();
statusStrip.SuspendLayout();
this.sidebar.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.menuButton)).BeginInit();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panel6.SuspendLayout();
this.SuspendLayout();
//
// statusStrip
//
statusStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(35)))), ((int)(((byte)(40)))), ((int)(((byte)(45)))));
statusStrip.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
statusStrip.Dock = System.Windows.Forms.DockStyle.Top;
statusStrip.Font = new System.Drawing.Font("Segoe UI", 10.8F);
statusStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible;
statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
statusStrip.ImeMode = System.Windows.Forms.ImeMode.On;
statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Close,
this.Networks});
statusStrip.Location = new System.Drawing.Point(0, 0);
statusStrip.Name = "statusStrip";
statusStrip.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
statusStrip.Size = new System.Drawing.Size(800, 31);
statusStrip.SizingGrip = false;
statusStrip.TabIndex = 1;
//
// Close
//
this.Close.ActiveLinkColor = System.Drawing.Color.White;
this.Close.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.Close.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Close.BackgroundImage")));
this.Close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.Close.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.Close.ForeColor = System.Drawing.Color.White;
this.Close.Image = ((System.Drawing.Image)(resources.GetObject("Close.Image")));
this.Close.ImageTransparentColor = System.Drawing.Color.Transparent;
this.Close.LinkColor = System.Drawing.Color.White;
this.Close.Margin = new System.Windows.Forms.Padding(20, 3, 0, 3);
this.Close.Name = "Close";
this.Close.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Close.RightToLeftAutoMirrorImage = true;
this.Close.Size = new System.Drawing.Size(20, 25);
this.Close.Text = "Close";
this.Close.VisitedLinkColor = System.Drawing.Color.White;
this.Close.Click += new System.EventHandler(this.Close_Click);
//
// Networks
//
this.Networks.ForeColor = System.Drawing.Color.White;
this.Networks.Image = ((System.Drawing.Image)(resources.GetObject("Networks.Image")));
this.Networks.ImageTransparentColor = System.Drawing.Color.White;
this.Networks.Margin = new System.Windows.Forms.Padding(40, 2, 0, 0);
this.Networks.Name = "Networks";
this.Networks.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.Networks.ShowDropDownArrow = false;
this.Networks.Size = new System.Drawing.Size(121, 29);
this.Networks.Text = "Networks";
this.Networks.ToolTipText = "Networks";
this.Networks.Click += new System.EventHandler(this.Networks_Click);
//
// sidebar
//
this.sidebar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(35)))), ((int)(((byte)(40)))), ((int)(((byte)(45)))));
this.sidebar.Controls.Add(this.panel1);
this.sidebar.Controls.Add(this.panel2);
this.sidebar.Controls.Add(this.panel3);
this.sidebar.Controls.Add(this.panel4);
this.sidebar.Controls.Add(this.panel5);
this.sidebar.Controls.Add(this.panel6);
this.sidebar.Location = new System.Drawing.Point(0, 0);
this.sidebar.MaximumSize = new System.Drawing.Size(200, 450);
this.sidebar.MinimumSize = new System.Drawing.Size(80, 450);
this.sidebar.Name = "sidebar";
this.sidebar.Size = new System.Drawing.Size(200, 450);
this.sidebar.TabIndex = 0;
//
// panel1
//
this.panel1.Controls.Add(this.Menu);
this.panel1.Controls.Add(this.menuButton);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 79);
this.panel1.TabIndex = 0;
//
// Menu
//
this.Menu.AutoSize = true;
this.Menu.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.Menu.ForeColor = System.Drawing.Color.White;
this.Menu.Location = new System.Drawing.Point(104, 29);
this.Menu.Name = "Menu";
this.Menu.Size = new System.Drawing.Size(57, 25);
this.Menu.TabIndex = 1;
this.Menu.Text = "Menu";
//
// menuButton
//
this.menuButton.Cursor = System.Windows.Forms.Cursors.Hand;
this.menuButton.Image = ((System.Drawing.Image)(resources.GetObject("menuButton.Image")));
this.menuButton.Location = new System.Drawing.Point(29, 29);
this.menuButton.Name = "menuButton";
this.menuButton.Size = new System.Drawing.Size(32, 37);
this.menuButton.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.menuButton.TabIndex = 0;
this.menuButton.TabStop = false;
this.menuButton.Click += new System.EventHandler(this.menuButton_Click);
//
// panel2
//
this.panel2.Controls.Add(this.Home);
this.panel2.Location = new System.Drawing.Point(3, 82);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 40);
this.panel2.TabIndex = 1;
//
// Home
//
this.Home.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Home.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.Home.ForeColor = System.Drawing.Color.White;
this.Home.Image = ((System.Drawing.Image)(resources.GetObject("Home.Image")));
this.Home.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Home.Location = new System.Drawing.Point(-12, -10);
this.Home.Name = "Home";
this.Home.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
this.Home.Size = new System.Drawing.Size(229, 62);
this.Home.TabIndex = 2;
this.Home.Text = " Home";
this.Home.UseVisualStyleBackColor = true;
//
// panel3
//
this.panel3.Controls.Add(this.Settings);
this.panel3.Location = new System.Drawing.Point(3, 128);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(200, 40);
this.panel3.TabIndex = 2;
//
// Settings
//
this.Settings.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Settings.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.Settings.ForeColor = System.Drawing.Color.White;
this.Settings.Image = ((System.Drawing.Image)(resources.GetObject("Settings.Image")));
this.Settings.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Settings.Location = new System.Drawing.Point(-12, -10);
this.Settings.Name = "Settings";
this.Settings.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
this.Settings.Size = new System.Drawing.Size(229, 62);
this.Settings.TabIndex = 2;
this.Settings.Text = " Settings";
this.Settings.UseVisualStyleBackColor = true;
//
// panel4
//
this.panel4.Controls.Add(this.Help);
this.panel4.Location = new System.Drawing.Point(3, 174);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(200, 40);
this.panel4.TabIndex = 3;
//
// Help
//
this.Help.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Help.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.Help.ForeColor = System.Drawing.Color.White;
this.Help.Image = ((System.Drawing.Image)(resources.GetObject("Help.Image")));
this.Help.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Help.Location = new System.Drawing.Point(-12, -10);
this.Help.Name = "Help";
this.Help.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
this.Help.Size = new System.Drawing.Size(229, 62);
this.Help.TabIndex = 2;
this.Help.Text = " Help";
this.Help.UseVisualStyleBackColor = true;
this.Help.Click += new System.EventHandler(this.Help_Click);
//
// panel5
//
this.panel5.Controls.Add(this.About);
this.panel5.Location = new System.Drawing.Point(3, 220);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(200, 40);
this.panel5.TabIndex = 4;
//
// About
//
this.About.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.About.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.About.ForeColor = System.Drawing.Color.White;
this.About.Image = ((System.Drawing.Image)(resources.GetObject("About.Image")));
this.About.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.About.Location = new System.Drawing.Point(-12, -10);
this.About.Name = "About";
this.About.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
this.About.Size = new System.Drawing.Size(229, 62);
this.About.TabIndex = 2;
this.About.Text = " About";
this.About.UseVisualStyleBackColor = true;
//
// panel6
//
this.panel6.Controls.Add(this.Software);
this.panel6.Location = new System.Drawing.Point(3, 266);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(200, 40);
this.panel6.TabIndex = 5;
//
// Software
//
this.Software.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Software.Font = new System.Drawing.Font("Segoe UI", 10.8F);
this.Software.ForeColor = System.Drawing.Color.White;
this.Software.Image = ((System.Drawing.Image)(resources.GetObject("Software.Image")));
this.Software.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Software.Location = new System.Drawing.Point(-12, -10);
this.Software.Name = "Software";
this.Software.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
this.Software.Size = new System.Drawing.Size(229, 62);
this.Software.TabIndex = 2;
this.Software.Text = " Software";
this.Software.UseVisualStyleBackColor = true;
this.Software.Click += new System.EventHandler(this.Software_Click);
//
// sidebarTimer
//
this.sidebarTimer.Tick += new System.EventHandler(this.sidebarTimer_Tick);
//
// NotifyIconHi
//
this.NotifyIconHi.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIconHi.Icon")));
this.NotifyIconHi.Text = "NotifyIconHi";
this.NotifyIconHi.Visible = true;
//
// Container
//
this.Container.Location = new System.Drawing.Point(200, 31);
this.Container.Name = "Container";
this.Container.Size = new System.Drawing.Size(600, 419);
this.Container.TabIndex = 2;
//
// App
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.Container);
this.Controls.Add(statusStrip);
this.Controls.Add(this.sidebar);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "App";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Copter V8/Rocket";
this.Shown += new System.EventHandler(this.App_Shown);
statusStrip.ResumeLayout(false);
statusStrip.PerformLayout();
this.sidebar.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.menuButton)).EndInit();
this.panel2.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.panel6.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button Home;
private System.Windows.Forms.Label Menu;
private System.Windows.Forms.PictureBox menuButton;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button Settings;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Button Help;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Button About;
private System.Windows.Forms.Timer sidebarTimer;
private System.Windows.Forms.NotifyIcon NotifyIconHi;
private System.Windows.Forms.ToolStripStatusLabel Close;
private System.Windows.Forms.ToolStripDropDownButton Networks;
private System.Windows.Forms.Panel Container;
private System.Windows.Forms.FlowLayoutPanel sidebar;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Button Software;
}
}
P.S(я не хочу писать на WPF)

Dock, аTableLayoutPanelвместо него. Плюс сFlowLayoutPanelпознакомтесь. – aepot Aug 20 '22 at 10:53Binding(в формах они тоже кстати есть и работают точно так же), и обязательно начать писать именно по правилам шаблона проектирования MVVM. Если все сделаете правильно, наступит счастье, а винформы покажутся ночным кошмаром. Ну хотя-бы вот пример или вот. – aepot Aug 20 '22 at 11:10