I have a WinForms application with a RichTextBox
control on the form. Right now, I have the AcceptsTabs
property set to true so that when Tab<
Add a new class to override your RichTextBox
:
class MyRichTextBox : RichTextBox
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == Keys.Tab)
{
SelectionLength = 0;
SelectedText = new string(' ', 4);
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
You can then drag your new control on to the Design view of your form:
Note: unlike with @LarsTec's answer, setting AcceptsTab
is not required here.