我正在制作一个文字处理器,并希望用户有能力粗体只有你在windows phone上选择的文本点击/按住/拖动。我知道如何使用Filebox.SelectedText检测用户选择的文本(filebox是文本框的名称),但不知道从哪里开始-如何获取所选文本并仅将其加粗?
注意:我使用的是ComponentOne的Rich Textbox控件。
发布于 2013-03-11 04:52:20
您可以使用RichTextBox.Selection属性。
例如:
private void ModifySelectedText()
{
// Determine if text is selected in the control.
if (richTextBox1.SelectionLength > 0)
{
// Set the color of the selected text in the control.
richTextBox1.SelectionColor = Color.Red;
// Set the font of the selected text to bold and underlined.
richTextBox1.SelectionFont = new Font("Arial",10,FontStyle.Bold | FontStyle.Underline);
// Protect the selected text from modification.
richTextBox1.SelectionProtected = true;
}
}https://stackoverflow.com/questions/15326661
复制相似问题