The solution is so painfully obvious, I wish I had thought of it sooner.
In the designer, all you have to do is change your Inherits line to inherit from the ListView object and remove that Autowhatsit in the InitializeComponent function.
ucListViewDoubleBuffered.Designer.vb:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ListViewDoubleBuffered
Inherits System.Windows.Forms.ListView
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
End Class
Then in the code behind, write a constructor and set its styles appropriately.
ucListViewDoubleBuffered.vb:
Imports System.Windows.Forms
Public Class ListViewDoubleBuffered
Inherits ListView
Public Sub New()
MyBase.New()
InitializeComponent()
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.Opaque, True)
End Sub
End Class
Bam. Instant double buffered control.Labels: Coding, Double Buffer, ListView, VB.NET
|