Preventing Controls from Redrawing
Disable redrawing of a Windows Forms control:
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr _
) As IntPtr
Private Const WM_SETREDRAW As Int32 = &HB
⋮
With Me.RichTextBox1
SendMessage( _
.Handle, WM_SETREDRAW, New IntPtr(CInt(False)), IntPtr.Zero _
)
' Manipulate contents.
For i As Integer = 0 To .TextLength
.SelectionStart = i
.SelectionLength = 1
.SelectionColor = Color.Red
.SelectionFont = New Font(.SelectionFont, FontStyle.Bold)
Next i
SendMessage( _
.Handle, WM_SETREDRAW, New IntPtr(CInt(True)), IntPtr.Zero _
)
.Refresh()
End With