看板 Visual_Basic 關於我們 聯絡資訊
請輸入專案類型(網站專案或者應用程式專案):應用程式 本來想說直接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
chinoyan:為什麼不用button做呢,該有的事件都有啊 02/20 08:57
jakevin:因為按鈕外型是特殊造型,用button事件 會有框線 02/20 14:46
horngsh:既然知道是路徑問題, 將圖改放到和主程式同一LEVEL的image 03/02 00:07
horngsh:資料夾中試試,如path=Application.StartupPath & "image\" 03/02 00:09