[英]VB.NET PictureBox / Controls
如此有趣的困境,我設法使標簽完全不可見,可以將其用於圖片某些部分的單擊事件。
然后,我使用該click事件使用picturebox3.visible = true調用另一個Picturebox使其成為焦點。
我遇到的問題是調用圖片框可見性時..新圖片框(不可見標簽)中的控件似乎不起作用或完全不存在於picturebox2中的圖片中。
我需要用大約30張不同的圖片來完成此操作,以便為某人創建一種“模擬器”項目。
有什么想法嗎? 如果需要,我可以發布代碼。 Picturebox + PictureBox上的控件=頭痛。
Public Class InvisibleLabel
Inherits Label
Public Sub New()
Me.SetStyle(ControlStyles.Opaque, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
End Sub
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim CC As CreateParams = MyBase.CreateParams
CC.ExStyle = CC.ExStyle Or &H20
Return CC
End Get
End Property
末級
這是不可見標簽的代碼,然后單擊圖片的某些部分時,我只是使用picturebox2.visible = true。
采用:
Private Sub PictureBox_MouseDown(sender As Object, e As MouseEventArgs) _
Handles PictureBox.MouseDown
'The code to change the picture goes here
End Sub
我做了3個文本框
X的textbox1,僅供您查看
用於Y的textbox2,僅供您查看
和
CurPicture比較當前圖像
我的畫框是300,300
私有子PictureBox1_MouseClick(作為對象發送,作為MouseEventArgs發送)處理PictureBox1.MouseClick
Dim LocX As Integer = e.X
Dim LocY As Integer = e.Y
TextBox1.Text = e.X.ToString
TextBox2.Text = e.Y.ToString
If LocX > 200 Then ' click right side op the picture , change LocX With LocY to make it bottom
If CurPicture.Text = "1" Then
PictureBox1.Image = My.Resources.Pic2
CurPicture.Text = "2"
ElseIf CurPicture.Text = "2" Then
PictureBox1.Image = My.Resources.Pic3
CurPicture.Text = "3"
ElseIf CurPicture.Text = "3" Then
PictureBox1.Image = My.Resources.Pic4
CurPicture.Text = "4"
ElseIf CurPicture.Text = "4" Then
PictureBox1.Image = My.Resources.Pic5
CurPicture.Text = "5"
ElseIf CurPicture.Text = "5" Then
PictureBox1.Image = My.Resources.Pic1
CurPicture.Text = "1"
End If
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = My.Resources.Pic1
CurPicture.Text = "1"
End Sub
希望這可以幫助您:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.