0

我想知道是否有一种方法可以向我的 winforms 添加过渡效果。

我的应用程序(vb.net)上有大约 3 个 winform,它们在屏幕顶部打开。我的客户关心美学,因此转换是表单在调用时显示的一项要求。

也许过渡不准确。我的意思是让表单在调用时从左向右移动。或从上到下。

是否有任何资源来帮助实现这一目标?

4

1 回答 1

2

The simplest way is to use a Timer and increase Opacity in a few steps over a second or two.

http://msdn.microsoft.com/library/system.windows.forms.form.opacity.aspx

An example:

Form1:

Public Class Form1

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim f As Form2
        f = New Form2
        f.Timer1.Enabled = True
        f.Timer1.Interval = 5
        f.Opacity = 0
        f.ShowDialog(Me)
    End Sub

End Class

Form2:

Public Class Form2
    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        If Me.Opacity >= 1 Then
            Timer1.Stop()
            Exit Sub
        End If
        Me.Opacity += 0.05
    End Sub
End Class
于 2013-07-06T21:49:44.757 回答