Jared,
I understand you are using .NET 1.x
In .NET 2.0 you can hide the context menu by setting ShortcutsEnabled to
*false*. Doing this will get rid of the context menu, but the shortcuts
won't work either.
In .NET 1.x (which is your case I believe) you can go with your solution or
you can derive your own class from the TextBox control and override the
WndProc and suppress the context menu if one is not set explicitly.
public class MyTextBox: TextBox
{
public MyTextBox()
{
}
private const int WM_CONTEXTMENU = 0x7b;
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_CONTEXTMENU && this.ContextMenu == null)
return;
base.WndProc (ref m);
}
}
This solution (yours also) works for all versions of windows forms and
preserves the shortcuts.