求大神指点 vb.net 用代码添加的数组图片框控件.怎么添加单击控件事件呢? 单击放大在单击就还原
PrivateSubButton1_Click(senderAsObject,eAsEventArgs)HandlesButton1.ClickDimPxAsIntege...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Px As Integer = 0
Dim Py As Integer = 0
ReDim pic(500)
Dim i As Int16
For i = 1 To 100
pic(i) = New PictureBox
With pic(i)
.Name = "pic_" & i.ToString
.Text = "pic_" & i.ToString
.Tag = i
.Size = New Point(105, 77)
End With
Px += 0
Py += 20
Next
FlowLayoutPanel1.Controls.AddRange(pic)
End Sub
我这里用代码添加了100个数组图片框控件 求大神指点 要怎么添加 图片框 单击事件呢? 比如我第一次单击那个图片框就放大那个图片框. 在单击放大的那个图片框的话 就缩小还原 , 展开
Dim Px As Integer = 0
Dim Py As Integer = 0
ReDim pic(500)
Dim i As Int16
For i = 1 To 100
pic(i) = New PictureBox
With pic(i)
.Name = "pic_" & i.ToString
.Text = "pic_" & i.ToString
.Tag = i
.Size = New Point(105, 77)
End With
Px += 0
Py += 20
Next
FlowLayoutPanel1.Controls.AddRange(pic)
End Sub
我这里用代码添加了100个数组图片框控件 求大神指点 要怎么添加 图片框 单击事件呢? 比如我第一次单击那个图片框就放大那个图片框. 在单击放大的那个图片框的话 就缩小还原 , 展开
展开全部
.....
Px += 0
Py += 20
AddHandler pic(i).Click, AddressOf Pic_Click '添加这一句,绑定单击图片框事件
Next
FlowLayoutPanel1.Controls.AddRange(pic)
End Sub
Dim l As Point, s As Size, f As Boolean
Private Sub Pic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim pic As PictureBox = CType(sender, PictureBox)
If f Then
pic.Location = l
pic.Size = s
f = False
Else
l = pic.Location
s = pic.Size
pic.BringToFront()
pic.Location = FlowLayoutPanel1.Location
pic.Size = FlowLayoutPanel1.Size
f = True
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询