2
A
回答
1
這應該做的工作:
Dim OldImage As Image
Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
OldImage = PictureBox1.Image 'This will store the image before changing. Set this in Form1_Load() handler
PictureBox1.Image = Image.FromFile("C:\xyz.jpg") 'Method 1 : This will load the image in memory
PictureBox1.ImageLocation = "C:\xyz.jpg" 'Method 2 : This will load the image from the filesystem and other apps won't be able to edit/delete the image
PictureBox1.Image = My.Resources.Image 'Method 3 : This will also load the image in memory from a resource in your appc
PictureBox1.Image = OldImage 'Set the image again to the old one
End Sub
2
保持圖像的列表,並從列表中specificying更改索引的圖片框的圖像:
簡單的例子有PictureBox
:
Public Class Form1
Private _Images As New List(Of Image)
Private _ImageIndex As Integer
Public Sub New()
InitializeComponent()
For i As Integer = 1 To 3
Dim bmp As New Bitmap(32, 32)
Using g As Graphics = Graphics.FromImage(bmp)
Select Case i
Case 1 : g.Clear(Color.Blue)
Case 2 : g.Clear(Color.Red)
Case 3 : g.Clear(Color.Green)
End Select
End Using
_Images.Add(bmp)
Next
End Sub
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.Click
If _Images.Count > 0 Then
PictureBox1.Image = _Images(_ImageIndex)
_ImageIndex += 1
If _ImageIndex > _Images.Count - 1 Then
_ImageIndex = 0
End If
End If
End Sub
End Class
相關問題
- 1. Vb.net改變圖片的顏色
- 2. 更改圖片onClick()
- 3. 事件onclick改變背景圖片
- 4. jQuery改變圖像onclick點擊和其他人
- 5. onclick改變一個鏈接的顏色,並返回所有其他的默認
- 6. 去一個片段的其他片段
- 7. 動態自動選擇,改變其他地方的圖片
- 8. 試圖改變一個圖片框c#
- 9. 改變一個在其表視圖
- 10. 通知onClick到其他片段
- 11. StreetViewPanorama - 如何更改爲其他圖片
- 12. 在vb.net中,是否有其他變量?
- 13. 如何更改單個圖片onClick?
- 14. HTML:更改圖片onclick?
- 15. 更改圖片OnClick&OnMouseover
- 16. Onclick(onmousdown)更改圖片
- 17. 關於其他圖片的圖片Android
- 18. 一個iframe在父頁中改變一個div的圖片
- 19. 點擊圖片查看改爲其他圖片
- 20. 點擊後改變圖標(其他圖標沒有改變)
- 21. React ES6 onClick更改其他組件
- 22. 圖片框不改變其大小
- 23. 不能在按下其他按鈕之後改變圖片的按鈕
- 24. 如何更改onClick事件上其他按鈕的圖像?
- 25. 如何改變其他圖像
- 26. overLap圖片由其他圖片
- 27. 在一個函數內改變圖像onclick
- 28. div css onclick改變多個圖像
- 29. 幾個圖像的onclick保持其他圖像
- 30. 改變的onclick
有沒有什麼方法可以使用這些方法中的任何一種來改變畫面? – HunderingThooves 2012-01-12 17:27:53
已更新的答案。 – Elmo 2012-01-12 17:29:45