Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用字符串的值来控制VB.net中的另一个控件?_Vb.net - Fatal编程技术网

如何使用字符串的值来控制VB.net中的另一个控件?

如何使用字符串的值来控制VB.net中的另一个控件?,vb.net,Vb.net,我一直在玩弄一些代码,我已经轻松地制作了50多个控件,所有控件都标有:PictureBox[XCoordinate][YCorrdinate](用我制作的小网格上的括号和内容的坐标替换它们) 问题是,在循环更新所有图片框时,使用控件是一件非常痛苦的事情。我想知道如何编写如下代码: 'This code assumes that the picture boxes are all initialized. Dim XCoordiante As Integer = 5 Dim YCorrdinate

我一直在玩弄一些代码,我已经轻松地制作了50多个控件,所有控件都标有:
PictureBox[XCoordinate][YCorrdinate]
(用我制作的小网格上的括号和内容的坐标替换它们)

问题是,在循环更新所有图片框时,使用控件是一件非常痛苦的事情。我想知道如何编写如下代码:

'This code assumes that the picture boxes are all initialized.
Dim XCoordiante As Integer = 5
Dim YCorrdinate As Integer = 2
PictureBox[XCoordinate]_[YCoordiante].Image = [Put Image Here]
我将把它放在一个循环中。有没有一种方法可以做到这一点,而不必手动键入所有内容,也不必冒着在案例陈述中遗漏某些内容的风险?此外,我还必须为我想做的每一种不同的更改(例如:标记或错误图像)重新键入它。


指针会有帮助吗?我真的不知道怎么做,但如果可能的话,这将非常有用。

创建它们时,将它们保存到列表中:

Private pList As New List(Of PictureBox)

Dim pic As New PictureBox
With Pic
    .Location = ... 
    ' etc
End With

Me.Controls.Add(pic)
pList.Add(pic)
假设它们是按某种顺序创建的:

For n As integer = 0 To pList.Count = 1
   ' add code to look at Plist(n).X and .Y to determine what to do (?)
   Plist(n).Image = ...
Next n

如果要捕获更多信息,请创建一个自定义的
PicBox类和其他信息,并将该列表设置为
list(myPicClass的)

X和Y坐标的上限是多少?
Me.controls(“picturebox”&XCoordiante.Tostring&“&YCorrdinate.Tostring”).Image=…
您最好将它们保存到一个列表(PictureBox)中,然后快速浏览列表,或者键入.Location或.Tag值。@rbaryYoung不是很高;1