
前提・やりたいこと
地図を描画するプログラムを作っており、ウィンドウに1000px×1000pxの地図を表示させるために、それと同等、もしくはそれ以上の大きさのFormに設定したいです。
発生している問題・エラーメッセージ
プロパティ内でSizeを変更しても、それよりも小さい値に戻される。(今回の場合、横が1300、縦が740より大きくならない)
試したこと
コンストラクタ内で大きさを宣言してみたが、エラーが生じた。
Form1.cs
1 public Form1() 2 { 3 InitializeComponent(); 4 AllocConsole(); 5 Form1 form = new Form1(); 6 form.Size = new Size(1000, 1000); 7 form.Show(); 8 }
エラー
以下のコードのコメントしている部分で例外を受け取っている。
予想としては
this.ClientSize = new System.Drawing.Size(1284, 701);
の部分がいけないのでと思い、値を変えてみたが、同じように例外をを受け取りました。
Form1.Designer.cs
1 private void InitializeComponent() 2 { 3 this.AuthorsDataSet = new System.Data.DataSet(); 4 this.DataLoadButton = new System.Windows.Forms.Button(); 5 this.ShowConsoleButton = new System.Windows.Forms.Button(); 6 this.pictureBox1 = new System.Windows.Forms.PictureBox(); 7 ((System.ComponentModel.ISupportInitialize)(this.AuthorsDataSet)).BeginInit(); 8 ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 9 this.SuspendLayout(); 10 // 11 // AuthorsDataSet 12 // 13 this.AuthorsDataSet.DataSetName = "AuthorsDataSet"; 14 // 15 // DataLoadButton 16 // 17 this.DataLoadButton.Location = new System.Drawing.Point(14, 55); 18 this.DataLoadButton.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); 19 this.DataLoadButton.Name = "DataLoadButton"; 20 this.DataLoadButton.Size = new System.Drawing.Size(125, 34); 21 this.DataLoadButton.TabIndex = 4; 22 this.DataLoadButton.Text = "data_load"; 23 this.DataLoadButton.UseVisualStyleBackColor = true; 24 this.DataLoadButton.Click += new System.EventHandler(this.DataLoadButton_Click); 25 // 26 // ShowConsoleButton 27 // 28 this.ShowConsoleButton.Location = new System.Drawing.Point(14, 13); 29 this.ShowConsoleButton.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); 30 this.ShowConsoleButton.Name = "ShowConsoleButton"; 31 this.ShowConsoleButton.Size = new System.Drawing.Size(192, 34); 32 this.ShowConsoleButton.TabIndex = 5; 33 this.ShowConsoleButton.Text = "Show Console"; 34 this.ShowConsoleButton.UseVisualStyleBackColor = true; 35 this.ShowConsoleButton.Click += new System.EventHandler(this.ShowConsoleButton_Click); 36 // 37 // pictureBox1 38 // 39 this.pictureBox1.BackColor = System.Drawing.Color.White; 40 this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 41 this.pictureBox1.Location = new System.Drawing.Point(14, 96); 42 this.pictureBox1.Name = "pictureBox1"; 43 this.pictureBox1.Size = new System.Drawing.Size(500, 500); 44 this.pictureBox1.TabIndex = 6; 45 this.pictureBox1.TabStop = false; 46 this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); 47 // 48 // Form1 49 // 50 this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 18F); 51 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 52 this.ClientSize = new System.Drawing.Size(1284, 701); 53 this.Controls.Add(this.pictureBox1); 54 this.Controls.Add(this.ShowConsoleButton); 55 this.Controls.Add(this.DataLoadButton); 56 this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); 57 this.Name = "Form1"; 58 this.Text = "Form1"; 59 ((System.ComponentModel.ISupportInitialize)(this.AuthorsDataSet)).EndInit(); 60 ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 61 this.ResumeLayout(false); //この部分で例外を受け取る 62 63 }
補足情報(FW/ツールのバージョンなど)
VisualStudio2019
C# .NET Framework 4.7.2
Windows Forms




回答2件
あなたの回答
tips
プレビュー