加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 07:45:52 所属栏目:百科 来源:网络整理
导读:?? 是要这样的代码?像这样的代码适合制作自定义漂亮的按钮 Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click Dim 背景图 = Button1.BackgroundImage If 背景图 Is Nothing Then Button1.BackgroundImage = Image.FromFile
??
是要这样的代码?像这样的代码适合制作自定义漂亮的按钮


     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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读