实现效果:
知识运用:
RichTextBox控件的SelectionAlignment属性 //获取或设置在当前选择或插入点的对齐方式
public HorizontalAlignment SelectionAlignment{get;set;} //参数:枚举值之一
实现代码:
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
} private void button2_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
} private void button3_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Right;
}