rich textbox
-
hi, the text in the rich textbox is underlined! when i enter a key in the textbox i want to have FontStyle.Regular:
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { textBox_Receivers.SelectionStart = 0; textBox_Receivers.SelectionLength = textBox_Receivers.ToString().Length; textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular); }
but when i enter only the one char (the one which i pressed) is in the textbox...why, the other text is cleared!? whats wrong? cu -- modified at 16:31 Tuesday 30th August, 2005 -
hi, the text in the rich textbox is underlined! when i enter a key in the textbox i want to have FontStyle.Regular:
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { textBox_Receivers.SelectionStart = 0; textBox_Receivers.SelectionLength = textBox_Receivers.ToString().Length; textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular); }
but when i enter only the one char (the one which i pressed) is in the textbox...why, the other text is cleared!? whats wrong? cu -- modified at 16:31 Tuesday 30th August, 2005The text box is doing exactly what all text boxes do when all the text is selected and you insert a letter. It takes the selected text and replaces it whith the new letter. You really shouldn't be surprised by your results. If you want to change the font and attach the new letter, then you need to clear your selected text before you leave the method.
-
The text box is doing exactly what all text boxes do when all the text is selected and you insert a letter. It takes the selected text and replaces it whith the new letter. You really shouldn't be surprised by your results. If you want to change the font and attach the new letter, then you need to clear your selected text before you leave the method.
-
SelectionLength = 0; That's the first thing that came to my mind. There are also arguments in the 'e' parameter that you can use. Cancel pretends the keydown never happend, sometimes called Suppress.
-
SelectionLength = 0; That's the first thing that came to my mind. There are also arguments in the 'e' parameter that you can use. Cancel pretends the keydown never happend, sometimes called Suppress.
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { textBox_Receivers.SelectionStart = 0; textBox_Receivers.SelectionLength = textBox_Receivers.Text.Length; textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular); textBox_Receivers.SelectionLength = 0; }
doesn't work...hm cu -
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { textBox_Receivers.SelectionStart = 0; textBox_Receivers.SelectionLength = textBox_Receivers.Text.Length; textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular); textBox_Receivers.SelectionLength = 0; }
doesn't work...hm curichTextBox1.SelectionStart = 0; richTextBox1.SelectionLength = richTextBox1.Text.Length; richTextBox1.SelectionFont = new Font("Arial", 8, FontStyle.Bold); richTextBox1.SelectionStart = richTextBox1.Text.Length; richTextBox1.SelectionLength = 0; This works fine when I do it.
-
richTextBox1.SelectionStart = 0; richTextBox1.SelectionLength = richTextBox1.Text.Length; richTextBox1.SelectionFont = new Font("Arial", 8, FontStyle.Bold); richTextBox1.SelectionStart = richTextBox1.Text.Length; richTextBox1.SelectionLength = 0; This works fine when I do it.
hi, thx perfect, but i have a problem if i select the whole text in the richtextbox and press clear or backspace then the whole text isn't cleared...hmmm!? but i think i also can do that with Rtf, i mean that with underline...? how? i saw:
textBox_Receivers.Rtf ...
by the time i like c# *hehe* cu -
hi, thx perfect, but i have a problem if i select the whole text in the richtextbox and press clear or backspace then the whole text isn't cleared...hmmm!? but i think i also can do that with Rtf, i mean that with underline...? how? i saw:
textBox_Receivers.Rtf ...
by the time i like c# *hehe* cuRtf is just the same text but with the formatting codes included. You would never want to set the font on your Rtf. The codes will never be seen. If you're asking how to do underline, it's part of the FontStyle just like Regular and Bold.
-
Rtf is just the same text but with the formatting codes included. You would never want to set the font on your Rtf. The codes will never be seen. If you're asking how to do underline, it's part of the FontStyle just like Regular and Bold.
-
if i select all the text in the richtextbox and if i press clear or backspace then all the text isn't cleared...hmmm!? why? cu