1

in C#, Winforms. I have a very wide form/panel, around 40,000 pixels wide. When i programatically add TextBoxes, and specify a textbox.Left > about 32767, the TextBoxes all stop at around a Left of 32767. The Microsoft Docs say the Conrol.Left property is Int32, but it is acting like it is Int16. I get no error, it just sticks all the TextBoxes around the 32767 Left point. Is this a limitation that can't be exceeded? thanks...

I've tried with a Panel, and directly on a Form, same result. see code.

namespace testTextBoxLeftPosition { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.AutoScroll = true; //add scrollbars to Form1 }

    private Int32 TBWidth = 100;
    private Int32 TBLeft;
    private Int32 TBTop;

    private void button1_Click(object sender, EventArgs e)
    {
        TBTop = 100;
        TBLeft = 50;
        TextBox tb1 = new TextBox();
        tb1.Width = TBWidth;
        tb1.Location = new Point(TBLeft, TBTop);
        tb1.Text = "tb1";
        this.Controls.Add(tb1);

        TBTop = 150;
        TBLeft = 32600;
        TextBox tb2 = new TextBox();
        tb2.Width = TBWidth;
        tb2.Location = new Point(TBLeft, TBTop);
        tb2.Text = "tb2";
        this.Controls.Add(tb2);

        TBTop = 200;
        TBLeft = 32700;
        TextBox tb3 = new TextBox();
        tb3.Width = TBWidth;
        tb3.Location = new Point(TBLeft, TBTop);
        tb3.Text = "tb3";
        this.Controls.Add(tb3);

        TBTop = 250;
        TBLeft = 32800;
        TextBox tb4 = new TextBox();
        tb4.Width = TBWidth;
        tb4.Location = new Point(TBLeft, TBTop);
        tb4.Text = "tb4";
        this.Controls.Add(tb4);

        TBTop = 300;
        TBLeft = 32900;
        //TextBox tb5 = new TextBox();
        //tb5.Width = TBWidth;
        //tb5.Location = new Point(TBLeft, TBTop);
        //tb5.Text = "tb5";
        //this.Controls.Add(tb5);

    }

    private void button2_Click(object sender, EventArgs e)
    {
        TBTop = 300;
        TBLeft = 32900;
        TextBox tb5 = new TextBox();
        tb5.Width = TBWidth;
        tb5.Location = new Point(TBLeft, TBTop);
        tb5.Text = "tb5";
        this.Controls.Add(tb5);
    }
}

}

what is also odd, is that if i uncomment the tb5 textbox, it seems to change the location of textboxes 2 thru 4.

eric K.
  • 43
  • 5

0 Answers0