Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'分隔面板 = SC1
'面板分隔中心寬度 = 400
'固定面板 0=panel1(右、上) 1=panel2(左、下)
VB_SplitContainer_FixedPanel(SC1, 200, 0)
SetUDCtrlData()
End Sub
Sub SetUDCtrlData()
' 宣告 7 個 NumericUpDown 控制項的陣列
Dim NUDs(7) As NumericUpDown
Dim LABs(7) As Label
For i As Integer = 0 To 7
'加入NumericUpDown =========================================
NUDs(i) = New NumericUpDown
' 設定 NumericUpDown 控制項的屬性,如位置、大小和文字內容等。
With NUDs(i)
.Location = New Point(0, 0)
.Size = New Size(80, 30)
.Text = "NUD" & CStr(i + 1)
End With
Dim s As Integer = 5
Dim x1 As Integer = 0
Dim y1 As Integer = 10
Dim W As Integer
Dim setx = 10
x1 = setx
For I = 0 To 7
W = LABs(I).Width '儲存舊的標籤顯示寬度
LABs(I).AutoSize = False
LABs(I).Width = W + 4 '舊的標籤顯示寬度 + 4
Next
For I = 0 To 7
'當前控制項的Y座標的位置
NUDs(I).Top = y1
LABs(I).Top = y1
LABs(I).Left = x1
NUDs(I).Left = x1 + LABs(I).Width + s
If I < 7 Then
x1 = NUDs(I).Left + NUDs(I).Width + s
If I = 2 Or I = 3 Or I = 5 Then '分割到下一列
y1 = y1 + NUDs(0).Height + s
x1 = setx
End If
End If
Next
End Sub
'指定 NumericUpDown 控制項的 ValueChange 事件
Private Sub NUDs_ValueChanged(sender As Object, e As EventArgs)
Dim w As Integer = 50
Dim h As Integer = 50
'================================================
'缺NumericUpDown(陣列).VALUE的值
'================================================
Dim bm As New Bitmap(w, h)
Dim gr As Graphics = Graphics.FromImage(bm)
VB6Line(gr, 0, 0, w, h, Color.Black, "B")
gr.Dispose()
PB1.Image = bm
End Sub
End Class
我在網路找資料都找不到呀
請高手指導一下
[attach]125471343[/attach]
後來我看懂了,得到的解答就是如下:
Imports System.IO
Public Class Form1
Dim LABs(7) As Label '設定在上面共用,程式就捉的到了
Dim NUDs(7) As NumericUpDown '設定在上面共用,程式就捉的到了
.
.
.
.
Private Sub NUDs_ValueChanged(sender As System.Object, e As System.EventArgs)
Dim w As Integer = NUD(0).VALUE
Dim h As Integer = NUD(1).VALUE