You can do this by deriving the TextBox, overriding the WndProc method and ignoring these mouse down messages.
[C#]
public class CustomTextBox : TextBox
{
protected override void WndProc( ref Message m )
{ // WM_NCLBUTTONDOWN WM_LBUTTONDOWN
if ( !( ReadOnly && (m.Msg == 0xa1 || m.Msg == 0x201) ) )
base.WndProc( ref m );
}
}
[Visual Basic]
Public Class CustomTextBox
Inherits TextBox
Protected Overrides Sub WndProc(ByRef m As Message)
' WM_NCLBUTTONDOWN WM_LBUTTONDOWN
If Not (Me.ReadOnly AndAlso (m.Msg = &HA1 OrElse m.Msg = &H201)) Then
MyBase.WndProc(m)
End If
End Sub
End Class
Contributed from George Shepherd's Windows Forms FAQ