Hi, yes I'm a student with homework problems, but I am trying. I need to display various shapes in a picture box, and am trying to do so via a combobox that the user can select from. My problem is clearing a previous selection when a new selection is made. Code to date is:
Public Class frmGraphics1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Populate cboShape with shapes
cboShape.Items.Add("Select a shape")
cboShape.Items.Add("Circle")
cboShape.Items.Add("Square")
cboShape.Items.Add("Rectangle")
'Set index to 0
cboShape.SelectedIndex = 0
End Sub
Private Sub cboShape_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboShape.SelectedIndexChanged
Dim GraphicsDisplay As Graphics
GraphicsDisplay = pboGraphics.CreateGraphics
If cboShape.SelectedIndex = 0 Then
Exit Sub
ElseIf cboShape.SelectedIndex = 1 Then
GraphicsDisplay.DrawEllipse(Pens.Blue, 10, 10, 150, 150)
ElseIf cboShape.SelectedIndex = 2 Then
GraphicsDisplay.DrawRectangle(Pens.Blue, 10, 10, 150, 150)
ElseIf cboShape.SelectedIndex = 3 Then
GraphicsDisplay.DrawRectangle(Pens.Blue, 10, 10, 250, 100)
End If
End Sub
End Class
Thank you, Brenda