以下给了我一个空引用错误。我怎样才能在避免错误的同时完成这个简单的任务?
谢谢!
编辑:L1、L2 等是我表单中的标签。
Dim labelArray(,) As Label = {{L1, L2, L3, L4}, {L5, L6, L7, L8}, {L9, L10, L11, L12}, {L13, L14, L15, L16}}
private sub button_click(stuff that goes in here)
labelArray(zeroPoint.X, zeroPoint.Y).BackColor = Color.LimeGreen
end sub
编辑:我通过在表单加载方法中执行以下操作来使其工作..
labelArray(0, 0) = Me.L1
labelArray(0, 1) = Me.L2
labelArray(0, 2) = Me.L3
labelArray(0, 3) = Me.L4
labelArray(1, 0) = Me.L5
labelArray(1, 1) = Me.L6
labelArray(1, 2) = Me.L7
labelArray(1, 3) = Me.L8
labelArray(2, 0) = Me.L9
labelArray(2, 1) = Me.L10
labelArray(2, 2) = Me.L11
labelArray(2, 3) = Me.L12
labelArray(3, 0) = Me.L13
labelArray(3, 1) = Me.L14
labelArray(3, 2) = Me.L15
labelArray(3, 3) = Me.L16