Tabcontrol控件的闪烁问题

前端之家收集整理的这篇文章主要介绍了Tabcontrol控件的闪烁问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

笔者在开发中发现,当调整窗体中的Tabcontrol控件大小时,如果tabcontrol控件中包含ListBox、DatagridView等较多控件时,易出现Tabcontrol控件不停闪烁的问题,严重影响应用程序的美观。

经过搜索和测试,发现解决办法是在tabcontrol控件所在的窗体添加如下的代码,即可彻底解决Tabcontrol控件的闪烁:

 Dim AntiFlicker As Boolean = False

 Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
 Get
 Dim cp As CreateParams = MyBase.CreateParams
 If AntiFlicker Then
 cp.ExStyle = cp.ExStyle Or &H2000000 'Turn on WS_EX_COMPOSITED
 End If
 Return cp
 End Get
 End Property

 '开始调整大小时启用抗闪烁
 Private Sub Form2_ResizeBegin(sender As Object,e As System.EventArgs) Handles Me.ResizeBegin
 AntiFlicker = True
 Me.MaximizeBox = True
 End Sub

 '调整完毕时关闭抗闪烁
 Private Sub Form2_ResizeEnd(sender As Object,e As System.EventArgs) Handles Me.ResizeEnd
 AntiFlicker = False
 Me.MaximizeBox = True
 End Sub
原文链接:https://www.f2er.com/vb/258218.html

猜你在找的VB相关文章