net中创建表单FadeIn和FadeOut

net中创建表单FadeIn和FadeOut

本文介绍了如何在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

推荐答案

'Me.Opacity = 0.99 ' Get rid of this
''fadeIn
Dim iCount As Integer
For iCount = 10 To 90 Step 5


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

11-01 19:33