vb里面图片怎么使按钮上面图片交替显示的代码

前端之家收集整理的这篇文章主要介绍了vb里面图片怎么使按钮上面图片交替显示的代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

是要这样的代码?像这样的代码适合制作自定义漂亮的按钮


     Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click
        Dim 背景图 = Button1.BackgroundImage
        If 背景图 Is Nothing Then
            Button1.BackgroundImage = Image.FromFile(System.Environment.CurrentDirectory + "\\熊猫.bmp")
            Button1.BackgroundImage.Tag = "熊猫"
            Button1.Text = ""
        Else
            Dim 景图 = Button1.BackgroundImage.Tag
            If 景图 = "熊猫" Then
                Button1.BackgroundImage = Image.FromFile(System.Environment.CurrentDirectory + "\\水滴.gif")
                Button1.BackgroundImage.Tag = "水滴"
            ElseIf 景图 = "水滴" Then
                Button1.BackgroundImage = Image.FromFile(System.Environment.CurrentDirectory + "\\双狮子.png")
                Button1.BackgroundImage.Tag = "双狮子"
            ElseIf 景图 = "双狮子" Then
                Button1.BackgroundImage = Image.FromFile(System.Environment.CurrentDirectory + "\\熊猫.bmp")
                Button1.BackgroundImage.Tag = "熊猫"
            End If
        End If
        Button1.Size = Button1.BackgroundImage.Size
        Me.CreateGraphics.Clear(Button1.BackColor)
    End Sub
这个例子不断点击按钮循环更换图片
        Me.ResizeRedraw = True
    Private Sub Form1_Paint(sender As Object,e As PaintEventArgs) Handles MyBase.Paint
        Dim 花篮 = Image.FromFile(System.Environment.CurrentDirectory + "\\花篮.jpg")
        e.Graphics.DrawImage(花篮,Me.Width,Me.Height)
    End Sub

原文链接:https://www.f2er.com/vb/257409.html

猜你在找的VB相关文章