L
Leon Friesema
Hiyall!
I have a RichTextBox inside a UserControl which should be able to
indent a block off text (or UnIndent for that matter) like the
SourceEditor of VS2003 or WinWord does.
All controls on the form (except for the RichTextBox) have
TabStop=False and I have a KeyDown event handler which calls the
IndentSelection function. No problem with the indenting (I've watched
when stepping through the code) except.. The e.Handled does not seem
to have any effect. I already created a new KeyUp event handler which
only states: e.Handled = true when a Tab-Key is pressed, but no luck..
Does anybody have any idea where this last TAB comes from? I already
tried the IsInput??? functions, but they have no effect whatsoever...
I'm lost here..
Thanks in advance, greetings,
L.
[CODE SNIPPET]
private void richTextBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if ((e.KeyValue == 9) && (e.Shift))
{
if (richTextBox1.SelectionLength != 0)
{
UnIndentSelection();
e.Handled = true;
};
e.Handled = true;
}
else if (e.KeyValue == 9)
{
if (richTextBox1.SelectionLength != 0)
{
IndentSelection();
e.Handled = true;
};
};
}
private void richTextBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyValue == 9)
{
e.Handled = true;
};
}
[/CODE SNIPPET]
I have a RichTextBox inside a UserControl which should be able to
indent a block off text (or UnIndent for that matter) like the
SourceEditor of VS2003 or WinWord does.
All controls on the form (except for the RichTextBox) have
TabStop=False and I have a KeyDown event handler which calls the
IndentSelection function. No problem with the indenting (I've watched
when stepping through the code) except.. The e.Handled does not seem
to have any effect. I already created a new KeyUp event handler which
only states: e.Handled = true when a Tab-Key is pressed, but no luck..
Does anybody have any idea where this last TAB comes from? I already
tried the IsInput??? functions, but they have no effect whatsoever...
I'm lost here..
Thanks in advance, greetings,
L.
[CODE SNIPPET]
private void richTextBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if ((e.KeyValue == 9) && (e.Shift))
{
if (richTextBox1.SelectionLength != 0)
{
UnIndentSelection();
e.Handled = true;
};
e.Handled = true;
}
else if (e.KeyValue == 9)
{
if (richTextBox1.SelectionLength != 0)
{
IndentSelection();
e.Handled = true;
};
};
}
private void richTextBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyValue == 9)
{
e.Handled = true;
};
}
[/CODE SNIPPET]