■98894 / inTopicNo.1) |
PictureBox にスクロールバーを付けて画像を表示する |
□投稿者/ 星は昴 (34回)-(2022/01/13(Thu) 21:35:01)
|
分類:[C#]
SplitContainer1 と SplitContainer2 を用意し、SplitContainer1.Panel2 に SplitContainer2 を入れ、SplitContainer2.Panel1 に TextBox、Panel2 に PictureBox を上下に配置します。下の PictureBox にスクロールバーを付けるために https://dobon.net/vb/dotnet/graphics/scrollimage.html を参考にしたのですが、うまくいきません。通常の Panel に PictureBox 放り込むと、確かにスクロールバーが出ることを確認したので、PictureBox をいったん取り出し、SplitContainer2.Panel2 に普通のPanel を入れ、その Panel に改めて PictureBox を放り込みましたが、やはりスクロールバーは出ません。何が原因でしょうか。すべてデザイナーでやりました。
// splitContainer1 this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1";
// splitContainer1.Panel2 this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); this.splitContainer1.Size = new System.Drawing.Size(800, 450); this.splitContainer1.SplitterDistance = 266; this.splitContainer1.TabIndex = 0;
// splitContainer2 this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
// splitContainer2.Panel1 this.splitContainer2.Panel1.Controls.Add(this.textBox1);
// splitContainer2.Panel2 this.splitContainer2.Panel2.AutoScroll = true; this.splitContainer2.Panel2.Controls.Add(this.panel1); this.splitContainer2.Size = new System.Drawing.Size(530, 450); this.splitContainer2.SplitterDistance = 176; this.splitContainer2.TabIndex = 0;
// panel1 this.panel1.AutoScroll = true; this.panel1.AutoSize = true; this.panel1.Controls.Add(this.Pb); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(530, 270); this.panel1.TabIndex = 0;
// textBox1 this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.textBox1.Location = new System.Drawing.Point(0, 0); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(530, 176); this.textBox1.TabIndex = 0;
// Pb(PictureBox) this.Pb.Dock = System.Windows.Forms.DockStyle.Fill; this.Pb.Location = new System.Drawing.Point(0, 0); this.Pb.Name = "Pb"; this.Pb.Size = new System.Drawing.Size(530, 270); this.Pb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.Pb.TabIndex = 0; this.Pb.TabStop = false;
|
|