The
KeyPress
event is raising
before the
TextChanged
event.
First, make sure that the
TabStop
property is
false
.
Second, the
+=
operator doesn't work for changing text color. So, you need to change the code into this:
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\t')
{
richTextBox1.SelectionColor = Color.Red;
e.Handled = true;
richTextBox1.AppendText("hell0");
}
}
Hope this helps.