c# – Form size is not responsive with any screens


I’ve been trying to make my form responsive that fit in any screen. This form attached to a panel. I have marked that panel in red box in this image. This form inside the panel(showed in red box) is fit well in another screen. but my screen show like this.

panel is highlighted with redbox

What i have done here is, I have created a main form called MainDashboard.cs and on top of that i have add a menu left and a panel right side which is showing the forms that user select from the menu. The problem is panel is not fitted with the form which displays through it.

Here is the MainDashboard.cs code.

namespace Invenova.Forms
{
    partial class MainDashboard
    {
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        private void InitializeComponent()
        {
            // 
            // panel1
            // 
            this.panel1.Location = new System.Drawing.Point(225, 109);
            this.panel1.Margin = new System.Windows.Forms.Padding(0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(1356, 759);
            this.panel1.TabIndex = 3;
            // 
            // MainDashboard
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.ClientSize = new System.Drawing.Size(1202, 659);
            this.Controls.Add(this.panel6);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.panel2);
            this.DoubleBuffered = true;
            this.Font = new System.Drawing.Font("Century Gothic", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
            this.Name = "MainDashboard";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "MainDashboard";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.MainDashboard_Load);
            this.panel2.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.panel3.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.panel6.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.Panel panel3;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Panel panel4;
        private System.Windows.Forms.Button button7;
        private System.Windows.Forms.Panel panel5;
        private System.Windows.Forms.Button button5;
        public System.Windows.Forms.Button button4;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Panel panel6;
        private System.Windows.Forms.Button button13;
        private System.Windows.Forms.Button button6;
        private System.Windows.Forms.Button button8;
        private System.Windows.Forms.Button button9;
        private System.Windows.Forms.Panel panel1;
    }
}

Here is the form code, that i’m trying to display in the panel in MainDashboard.cs

using System;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Invenova.Forms
{
    partial class SellsForm
    {
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        private void InitializeComponent()
        {
            this.SelsList = new System.Windows.Forms.ListView();
            this.NItems = new System.Windows.Forms.Label();
            this.Total = new System.Windows.Forms.Label();
            this.Discount = new System.Windows.Forms.Label();
            this.STotal = new System.Windows.Forms.Label();
            this.NDiscount = new System.Windows.Forms.NumericUpDown();
            this.NQuentity = new System.Windows.Forms.NumericUpDown();
            this.ItemPrice = new System.Windows.Forms.Label();
            this.Remove = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.Add = new System.Windows.Forms.Button();
            this.Bill = new System.Windows.Forms.Button();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.ItemNameCombo = new System.Windows.Forms.ComboBox();
            this.BarCodeCombo = new System.Windows.Forms.ComboBox();
            this.PMode = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.showBalance = new System.Windows.Forms.Label();
            this.PayAmount = new System.Windows.Forms.NumericUpDown();
            this.save = new System.Windows.Forms.Button();
            this.list = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.NDiscount)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.NQuentity)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.PayAmount)).BeginInit();
            this.SuspendLayout();
            // 
            // SelsList
            // 
            this.SelsList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.SelsList.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.SelsList.HideSelection = false;
            this.SelsList.Location = new System.Drawing.Point(26, 247);
            this.SelsList.Name = "SelsList";
            this.SelsList.Size = new System.Drawing.Size(1762, 928);
            this.SelsList.TabIndex = 6;
            this.SelsList.UseCompatibleStateImageBehavior = false;
            // 
            // NItems
            // 
            this.NItems.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.NItems.AutoSize = true;
            this.NItems.Location = new System.Drawing.Point(1814, 247);
            this.NItems.Name = "NItems";
            this.NItems.Size = new System.Drawing.Size(179, 39);
            this.NItems.TabIndex = 1;
            this.NItems.Text = "No. Items :";
            // 
            // Total
            // 
            this.Total.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Total.AutoSize = true;
            this.Total.Location = new System.Drawing.Point(1816, 313);
            this.Total.Name = "Total";
            this.Total.Size = new System.Drawing.Size(107, 39);
            this.Total.TabIndex = 2;
            this.Total.Text = "Total :";
            // 
            // Discount
            // 
            this.Discount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Discount.AutoSize = true;
            this.Discount.Location = new System.Drawing.Point(1814, 379);
            this.Discount.Name = "Discount";
            this.Discount.Size = new System.Drawing.Size(169, 39);
            this.Discount.TabIndex = 3;
            this.Discount.Text = "Discount :";
            // 
            // STotal
            // 
            this.STotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.STotal.AutoSize = true;
            this.STotal.Location = new System.Drawing.Point(1813, 445);
            this.STotal.Name = "STotal";
            this.STotal.Size = new System.Drawing.Size(173, 39);
            this.STotal.TabIndex = 4;
            this.STotal.Text = "Sub Total :";
            // 
            // NDiscount
            // 
            this.NDiscount.Location = new System.Drawing.Point(1195, 72);
            this.NDiscount.Name = "NDiscount";
            this.NDiscount.Size = new System.Drawing.Size(174, 47);
            this.NDiscount.TabIndex = 3;
            this.NDiscount.ValueChanged += new System.EventHandler(this.RecordeChange);
            // 
            // NQuentity
            // 
            this.NQuentity.Location = new System.Drawing.Point(1008, 72);
            this.NQuentity.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.NQuentity.Name = "NQuentity";
            this.NQuentity.Size = new System.Drawing.Size(160, 47);
            this.NQuentity.TabIndex = 3;
            this.NQuentity.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.NQuentity.ValueChanged += new System.EventHandler(this.RecordeChange);
            // 
            // ItemPrice
            // 
            this.ItemPrice.AutoSize = true;
            this.ItemPrice.Location = new System.Drawing.Point(20, 157);
            this.ItemPrice.Name = "ItemPrice";
            this.ItemPrice.Size = new System.Drawing.Size(191, 39);
            this.ItemPrice.TabIndex = 12;
            this.ItemPrice.Text = "Item Price :";
            // 
            // Remove
            // 
            this.Remove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Remove.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.Remove.FlatAppearance.BorderSize = 0;
            this.Remove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Remove.ForeColor = System.Drawing.Color.White;
            this.Remove.Location = new System.Drawing.Point(1276, 140);
            this.Remove.Name = "Remove";
            this.Remove.Size = new System.Drawing.Size(208, 72);
            this.Remove.TabIndex = 13;
            this.Remove.Text = "Remove";
            this.Remove.UseVisualStyleBackColor = true;
            this.Remove.Click += new System.EventHandler(this.ClickRemove);
            // 
            // button2
            // 
            this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.button2.FlatAppearance.BorderSize = 0;
            this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.button2.ForeColor = System.Drawing.Color.White;
            this.button2.Location = new System.Drawing.Point(1045, 140);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(208, 72);
            this.button2.TabIndex = 5;
            this.button2.Text = "Clear";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            // 
            // Add
            // 
            this.Add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Add.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.Add.FlatAppearance.BorderSize = 0;
            this.Add.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Add.ForeColor = System.Drawing.Color.White;
            this.Add.Location = new System.Drawing.Point(807, 140);
            this.Add.Name = "Add";
            this.Add.Size = new System.Drawing.Size(208, 72);
            this.Add.TabIndex = 4;
            this.Add.Text = "Add";
            this.Add.UseVisualStyleBackColor = false;
            this.Add.Click += new System.EventHandler(this.Add_Click);
            // 
            // Bill
            // 
            this.Bill.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.Bill.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.Bill.FlatAppearance.BorderSize = 0;
            this.Bill.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.Bill.ForeColor = System.Drawing.Color.White;
            this.Bill.Location = new System.Drawing.Point(1821, 1087);
            this.Bill.Name = "Bill";
            this.Bill.Size = new System.Drawing.Size(315, 88);
            this.Bill.TabIndex = 9;
            this.Bill.Text = "Bill (F10)";
            this.Bill.UseVisualStyleBackColor = true;
            this.Bill.Click += new System.EventHandler(this.Bill_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(19, 19);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(152, 39);
            this.label2.TabIndex = 17;
            this.label2.Text = "Barcode";
            // 
            // label3
            // 
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(526, 19);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(192, 39);
            this.label3.TabIndex = 18;
            this.label3.Text = "Item Name";
            // 
            // label4
            // 
            this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(1000, 21);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(149, 39);
            this.label4.TabIndex = 19;
            this.label4.Text = "Quentity";
            // 
            // label5
            // 
            this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(1187, 19);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(151, 39);
            this.label5.TabIndex = 20;
            this.label5.Text = "Discount";
            // 
            // ItemNameCombo
            // 
            this.ItemNameCombo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.ItemNameCombo.FormattingEnabled = true;
            this.ItemNameCombo.Location = new System.Drawing.Point(534, 72);
            this.ItemNameCombo.Name = "ItemNameCombo";
            this.ItemNameCombo.Size = new System.Drawing.Size(441, 47);
            this.ItemNameCombo.TabIndex = 1;
            this.ItemNameCombo.TextUpdate += new System.EventHandler(this.ItemNameComboBox_TextUpdate);
            this.ItemNameCombo.Leave += new System.EventHandler(this.ItemName_Leave);
            // 
            // BarCodeCombo
            // 
            this.BarCodeCombo.FormattingEnabled = true;
            this.BarCodeCombo.Location = new System.Drawing.Point(27, 72);
            this.BarCodeCombo.Name = "BarCodeCombo";
            this.BarCodeCombo.Size = new System.Drawing.Size(465, 47);
            this.BarCodeCombo.TabIndex = 0;
            this.BarCodeCombo.TextUpdate += new System.EventHandler(this.BarCodeComboBox_TextUpdate);
            this.BarCodeCombo.Leave += new System.EventHandler(this.BarCode_Leave);
            // 
            // PMode
            // 
            this.PMode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.PMode.FormattingEnabled = true;
            this.PMode.Items.AddRange(new object[] {
            "CASH",
            "CARD"});
            this.PMode.Location = new System.Drawing.Point(1825, 713);
            this.PMode.Name = "PMode";
            this.PMode.Size = new System.Drawing.Size(311, 47);
            this.PMode.TabIndex = 8;
            // 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(1820, 647);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(324, 39);
            this.label1.TabIndex = 25;
            this.label1.Text = "Payment Mode (F7)";
            // 
            // label6
            // 
            this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(1814, 511);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(172, 39);
            this.label6.TabIndex = 26;
            this.label6.Text = "Cash (F6):";
            // 
            // showBalance
            // 
            this.showBalance.AutoSize = true;
            this.showBalance.Location = new System.Drawing.Point(1817, 581);
            this.showBalance.Name = "showBalance";
            this.showBalance.Size = new System.Drawing.Size(156, 39);
            this.showBalance.TabIndex = 27;
            this.showBalance.Text = "Balance:";
            // 
            // PayAmount
            // 
            this.PayAmount.Location = new System.Drawing.Point(1992, 511);
            this.PayAmount.Maximum = new decimal(new int[] {
            -559939585,
            902409669,
            54,
            0});
            this.PayAmount.Name = "PayAmount";
            this.PayAmount.Size = new System.Drawing.Size(144, 47);
            this.PayAmount.TabIndex = 7;
            this.PayAmount.ValueChanged += new System.EventHandler(this.PayAmount_ValueChanged);
            // 
            // save
            // 
            this.save.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.save.FlatAppearance.BorderSize = 0;
            this.save.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.save.ForeColor = System.Drawing.Color.White;
            this.save.Location = new System.Drawing.Point(1820, 972);
            this.save.Name = "save";
            this.save.Size = new System.Drawing.Size(315, 88);
            this.save.TabIndex = 28;
            this.save.Text = "save";
            this.save.UseVisualStyleBackColor = true;
            this.save.Click += new System.EventHandler(this.save_Click);
            // 
            // list
            // 
            this.list.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(122)))));
            this.list.FlatAppearance.BorderSize = 0;
            this.list.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.list.ForeColor = System.Drawing.Color.White;
            this.list.Location = new System.Drawing.Point(1820, 857);
            this.list.Name = "list";
            this.list.Size = new System.Drawing.Size(315, 88);
            this.list.TabIndex = 29;
            this.list.Text = "Saved List";
            this.list.UseVisualStyleBackColor = true;
            this.list.Click += new System.EventHandler(this.list_Click);
            // 
            // SellsForm
            // 
            this.AccessibleRole = System.Windows.Forms.AccessibleRole.Column;
            this.AutoScaleDimensions = new System.Drawing.SizeF(192F, 192F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.AutoSize = true;
            this.ClientSize = new System.Drawing.Size(2170, 1215);
            this.Controls.Add(this.list);
            this.Controls.Add(this.save);
            this.Controls.Add(this.PayAmount);
            this.Controls.Add(this.showBalance);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.PMode);
            this.Controls.Add(this.BarCodeCombo);
            this.Controls.Add(this.ItemNameCombo);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.Bill);
            this.Controls.Add(this.Add);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.Remove);
            this.Controls.Add(this.ItemPrice);
            this.Controls.Add(this.NQuentity);
            this.Controls.Add(this.NDiscount);
            this.Controls.Add(this.STotal);
            this.Controls.Add(this.Discount);
            this.Controls.Add(this.Total);
            this.Controls.Add(this.NItems);
            this.Controls.Add(this.SelsList);
            this.Cursor = System.Windows.Forms.Cursors.Arrow;
            this.Font = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "SellsForm";
            this.Text = "SellsForm";
            ((System.ComponentModel.ISupportInitialize)(this.NDiscount)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.NQuentity)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.PayAmount)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.ListView SelsList;
        private System.Windows.Forms.Label NItems;
        private System.Windows.Forms.Label Total;
        private System.Windows.Forms.Label Discount;
        private System.Windows.Forms.Label STotal;
        private System.Windows.Forms.NumericUpDown NDiscount;
        private System.Windows.Forms.NumericUpDown NQuentity;
        private System.Windows.Forms.Label ItemPrice;
        private System.Windows.Forms.Button Remove;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button Add;
        private System.Windows.Forms.Button Bill;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.ComboBox ItemNameCombo;
        private System.Windows.Forms.ComboBox BarCodeCombo;
        //private System.Windows.Forms.ComboBox CustomerNameCombo;
        private System.Windows.Forms.ComboBox PMode;
        private Label label1;
        private Label label6;
        private Label showBalance;
        private NumericUpDown PayAmount;
        private System.Windows.Forms.Button save;
        private System.Windows.Forms.Button list;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *