private void CenterButton_Click(object sender, EventArgs e) { if (TextRichTextBox.SelectionAlignment == HorizontalAlignment.Center) { TextRichTextBox.SelectionAlignment = HorizontalAlignment.Left; } else { TextRichTextBox.SelectionAlignment = HorizontalAlignment.Center; } TextRichTextBox.Focus(); }
private void SizeTextBox_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar < 45 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 13) { e.Handled = true; } else if (e.KeyChar == 13) { TextBox txt = (TextBox)sender; if (txt.Text.Length > 0) { ChangeFontSize(txt.Text); } e.Handled = true; TextRichTextBox.Focus(); } }
private void UnderlineButton_Click(object sender, EventArgs e) { Font newFont; Font oldFont; oldFont = TextRichTextBox.SelectionFont; if (oldFont.Underline) { newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Underline); } else { newFont = new Font(oldFont, oldFont.Style | FontStyle.Underline); } //setting new font and focus on text area TextRichTextBox.SelectionFont = newFont; TextRichTextBox.Focus(); }