Option Strict On '環境 'Vista 'Visual Basic 2008 'このコードの実行に責任は保障しません 'PictureBox1とComboBox1を用意する Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load With Me.ComboBox1.Items .Add("四角") .Add("三角") .Add("丸") End With '項目の編集を禁止する ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Dim g As Graphics = e.Graphics Select Case ComboBox1.SelectedIndex Case 0 '四角 g.DrawRectangle(Pens.Black, 0, 0, PictureBox1.Width - 1, PictureBox1.Height - 1) Case 1 '三角 g.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), 0, 0, PictureBox1.Height - 1) g.DrawLine(Pens.Black, 0, PictureBox1.Height - 1, PictureBox1.Width, PictureBox1.Height - 1) g.DrawLine(Pens.Black, PictureBox1.Width - 1, PictureBox1.Height - 1, CInt(PictureBox1.Width / 2), 0) Case 2 '丸 g.DrawEllipse(Pens.Black, 0, 0, PictureBox1.Width - 1, PictureBox1.Height - 1) End Select End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged PictureBox1.Invalidate() End Sub End Class