VB.NET中的“命令按钮"滑动效果 [英] Command Button slide effect in VB.NET
本文介绍了VB.NET中的“命令按钮"滑动效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了一个代码,以使5个命令按钮具有滑动效果.它可以在默认背景下正常运行,但是当我更改表单的不透明度或将图片放在背景中时,它的行为会比正常情况下要慢得多.可能是什么问题?解决任何想法.这是代码.
I have written a code to give a sliding effect to 5 command buttons. It runs fine with default background but when i change the opacity of the form OR put a picture in the background it behaves slower rather much slower than what it does normally. What might be the issue? Any ideas to resolve it. Here is the code.
Public Class Form1
Dim slidevar As Integer = -10
Dim slidevar1 As Integer = -60
Dim slidevar2 As Integer = -120
Dim slidevar3 As Integer = -180
Dim slidevar4 As Integer = -240
Dim delayvar As Integer = -300
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Location = New Point(-1000, 10)
Button2.Location = New Point(-1000, 80)
Button3.Location = New Point(-1000, 120)
Button4.Location = New Point(-1000, 160)
Button5.Location = New Point(-1000, 200)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
slidevar = 0
slidevar1 = 0
slidevar2 = 0
slidevar3 = 0
slidevar4 = 0
Button1.Location = New Point(-1000, 10)
Button2.Location = New Point(-1000, 80)
Button3.Location = New Point(-1000, 120)
Button4.Location = New Point(-1000, 160)
Button5.Location = New Point(-1000, 200)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If slidevar < 65 Then
Button1.Location = New Point(slidevar, 10)
slidevar += 6
If slidevar4 > 65 Then
Timer1.Enabled = False
End If
End If
For delayvar = 1 To 100
Next
If slidevar1 < 65 Then
Button2.Location = New Point(slidevar1, 80)
slidevar1 += 5
End If
For delayvar = 1 To 100
Next
If slidevar2 < 65 Then
Button3.Location = New Point(slidevar2, 120)
slidevar2 += 4
End If
For delayvar = 1 To 100
Next
If slidevar3 < 65 Then
Button4.Location = New Point(slidevar3, 160)
slidevar3 += 3
End If
For delayvar = 1 To 100
Next
If slidevar4 < 65 Then
Button5.Location = New Point(slidevar4, 200)
slidevar4 += 2
End If
End Sub
End Class
推荐答案
查看表单的DoubleBuffered
属性,这将有助于重新绘制
Have a look at your form''s DoubleBuffered
property this should help with the repaint
这篇关于VB.NET中的“命令按钮"滑动效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文