如何在vb.net中创建表单FadeIn和FadeOut [英] How to make a form FadeIn and FadeOut in vb.net

查看:76
本文介绍了如何在vb.net中创建表单FadeIn和FadeOut的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨再次专家。使我的form2淡入淡出的代码看起来像一个弹出屏幕。我想让它变得平滑,就像它渐渐消失一样。



Hi again experts.The code to make my form2 fadesIn looks like a pop-up screen. I want to make it smooth same like when its fading out.

Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Opacity = 0.99

        ''fadeIn
        Dim iCount As Integer

        For iCount = 90 To 10 Step -5
            Me.Opacity = iCount / 100
            Me.Refresh()
            Threading.Thread.Sleep(100)
            Me.Opacity = 0.99
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ''fadeOut
        Dim iCount As Integer

        For iCount = 90 To 10 Step -10
            Me.Opacity = iCount / 100
            Me.Refresh()
            Threading.Thread.Sleep(50)
        Next

        Me.Close()
    End Sub
End Class

推荐答案

在你的Form2_Load事件中你的循环方向错误......你需要以低不透明度开始并向上工作......

In your Form2_Load event your loop is going in the wrong direction ... you need to start with low opacity and work upwards ...
'Me.Opacity = 0.99 ' Get rid of this
''fadeIn
Dim iCount As Integer
For iCount = 10 To 90 Step 5


这篇关于如何在vb.net中创建表单FadeIn和FadeOut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆