一种控制模拟的形式。一种表示彩色玻璃窗的形式。
我有一个NumericUpDown1
包含数字列表的数字列表SecondForm
Dim Redpen As New Pen(Color.Red)
Dim i As Integer
Dim MyGraphicsClass As Graphics = Me.CreateGraphics
Dim a, b, c, d As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
a = 0
b = 20
c = 30
d = 50
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
NumericUpDown1.Dock = System.Windows.Forms.DockStyle.None
NumericUpDown1.Maximum = 7
NumericUpDown1.Minimum = 1
Controls.Add(NumericUpDown1)
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
SecondForm.Show()
If NumericUpDown1.DecimalPlaces = 1 Then
MyGraphicsClass.DrawLine(Pens.Red, a, b, a, b)
End If
Number_Of_Lines = 2
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 2 Then
MyGraphicsClass.DrawLine(Pens.Red, a, c, a, c)
End If
Next i
Number_Of_Lines = 3
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 3 Then
MyGraphicsClass.DrawLine(Pens.Red, a, d, a, d)
End If
Next i
Number_Of_Lines = 4
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 4 Then
MyGraphicsClass.DrawLine(Pens.Red, a, c, a, c)
End If
Next i
Number_Of_Lines = 5
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 5 Then
MyGraphicsClass.DrawLine(Pens.Red, a, b, a, b)
End If
Next i
Number_Of_Lines = 6
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 6 Then
MyGraphicsClass.DrawLine(Pens.Red, a, c, a, c)
End If
Next i
Number_Of_Lines = 7
For i = 1 Number_Of_Lines Step 1
If NumericUpDown1.DecimalPlaces = 7 Then
MyGraphicsClass.DrawLine(Pens.Red, a, c, a, c)
End If
Next i
End Sub
结束类