Imports System Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Public Class Form1 Private WithEvents PictureBox1 As PictureBox Private WithEvents Panel1 As Panel Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load PictureBox1 = New PictureBox() With {.Name = "PictureBox1"} Panel1 = New Panel() With {.Name = "Panel1"} PictureBox1.Margin = New Padding(0) PictureBox1.BorderStyle = BorderStyle.FixedSingle PictureBox1.BackColor = Color.Transparent 'PictureBox1.SetBounds(0, 0, 300, 2000) 'Panel より狭い PictureBox PictureBox1.SetBounds(0, 0, 2000, 2000) 'Panel より広い PictureBox Panel1.BackgroundImage = Me.Icon.ToBitmap() Panel1.BorderStyle = BorderStyle.Fixed3D Panel1.BackColor = Color.WhiteSmoke Panel1.SetBounds(30, 30, 350, 300) Panel1.Controls.Add(PictureBox1) Me.Controls.Add(Panel1) Panel1.AutoScroll = False Panel1.HorizontalScroll.Enabled = False Panel1.HorizontalScroll.Visible = False Panel1.HorizontalScroll.Maximum = 0 Panel1.AutoScroll = True '検証時にスクロール状況が分かるよう、グラデーションに塗っておく Dim canvas As New Bitmap(PictureBox1.Width, PictureBox1.Height) Using g = Graphics.FromImage(canvas), gb As New LinearGradientBrush( g.VisibleClipBounds, Color.FromArgb(223, Color.LightGreen), Color.FromArgb(32, Color.PaleTurquoise), LinearGradientMode.Vertical) g.FillRectangle(gb, g.VisibleClipBounds) End Using PictureBox1.Image = canvas End Sub End Class