[.NET] 動態按鈕的製作
請輸入專案類型(網站專案或者應用程式專案):應用程式
本來想說直接picturebox來放
但好像沒有跟VB6一樣 Picturebox1.Picture = LoadPicture("......")
下去寫
改用書上教的 但是圖片都不會顯示也不會更動 好像是路徑問題
圖片資料夾放置在 WindowsApplication1 之下
以下是這段功能的程式碼
Dim path As String = Application.StartupPath & "\..\Image\"
Dim PlayImage As Boolean
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PictureBox1.Click
'打開報名系統
Dim sign_up1 As New sign_up
sign_up.Show()
End Sub
Sub setICON()
'報名系統
PictureBox1.Tag = New String() {"011.gif", "012.gif", "013.gif"}
End Sub
Sub ShowICON(ByVal sender As Object, ByVal index As Integer)
Dim ctl As PictureBox
ctl = CType(sender, PictureBox)
If (ctl Is PictureBox1) AndAlso index = 0 AndAlso PlayImage Then
'讓play 按鈕為Down的狀態
index = 2
End If
Dim strFile As String = path & ctl.Tag(index)
If System.IO.File.Exists(strFile) Then
ctl.Image = Image.FromFile(strFile)
End If
End Sub
Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles PictureBox1.MouseEnter
ShowICON(sender, 1)
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles PictureBox1.MouseLeave
ShowICON(sender, 0)
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
ShowICON(sender, 2)
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
ShowICON(sender, 1)
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.75.85
推
02/20 08:57, , 1F
02/20 08:57, 1F
→
02/20 14:46, , 2F
02/20 14:46, 2F
推
03/02 00:07, , 3F
03/02 00:07, 3F
→
03/02 00:09, , 4F
03/02 00:09, 4F