我真的无法弄清楚我将如何编写流程代码。
For Each dtrow In camBtnDtable.Rows
Dim cameraNumber = camBtnDtable.Select("ButtonName =" & " '" & "foo" & "'")(0)("cameraID")
Dim nBtn As New Button
nBtn.Text = "C-" & 'this should be cameraNumber e.g "C-01"
nBtn.Name = 'select from the database, I don't know if this is still important though
nBtn.Location = 'select x and y from database where name is this
AddHandler nBtn.Click, AddressOf nBtn_Click
picture.Controls.Add(nBtn)
Next
这是一个混乱的代码,但一般来说,我想要的是从访问数据库加载按钮的属性。
答案 0 :(得分:1)
Dim Btn as Button
' assumes the camBtnDtable is something Like Select * from buttons
For Each dtRow in camBtnDtable.Rows
Btn = New Button
Btn.Name = dtRow.CameraButtonNameColumn
Btn.Text = dtRow.CameraButtonTextColumn
Btn.Location = dtRow.CameraButtonLocationColumn
' or
Btn.Location = New Point(dtRow.CameraButtonXColumn,
dtRow.CameraButtonYColumn)
picture.Controls.Add(Btn) ' ??? picture? not form?
AddHandler nBtn.Click, AddressOf nBtn_Click
Next
单行将包含按钮的所有数据,因此只需循环遍历行。