- 題名: PictureBoxの複数画像切り替え
 - 日時: 2003/07/02 15:45:50
 - ID: 107
 - この記事の返信元: 
- (なし)
 
 - この記事への返信: 
- [111] Re[1]: PictureBoxの複数画像切り替え2003/07/03 4:01:20
 
 - ツリーを表示
 
■No107に返信(wecanworkitoutさんの記事)
> VB.Netで,一つのPictureBoxに,場所を指定してjpeg画像を挿入するということは
> できたのですが,そこをComboBoxで切り替えて(1枚目,2枚目,…),
> 複数の画像を表示させるという
> 方法ができません。ご教授お願いいたします。
次のような感じでどうでしょうか?
Private _currentImage As Bitmap
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Select Case ComboBox1.SelectedIndex
        Case 0
            _currentImage = New Bitmap("1.bmp")
        Case 1
            _currentImage = New Bitmap("2.bmp")
        Case 2
            _currentImage = New Bitmap("3.bmp")
    End Select
    PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) _
    Handles PictureBox1.Paint
    If Not _currentImage Is Nothing Then
        e.Graphics.DrawImage(_currentImage, 0, 0)
    End If
End Sub
VB.Netで,一つのPictureBoxに,場所を指定してjpeg画像を挿入するということはできたのですが,そこをComboBoxで切り替えて(1枚目,2枚目,…),複数の画像を表示させるという
方法ができません。ご教授お願いいたします。