首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

RichTextBox选中项正当中

2012-09-10 
RichTextBox选中项居中如题,并不是让整个文本居中所以C# code TextAlignment align TextAlignment.Left

RichTextBox选中项居中
如题,并不是让整个文本居中
所以

C# code
 TextAlignment align = TextAlignment.Left;                switch ((this.cmbStyles.SelectedValue as ComboBoxItem).Tag.ToString())                {                    case "左对齐":                        align = TextAlignment.Left;                        break;                    case "居中":                        align = TextAlignment.Center;                        break;                    case "右对齐":                        align = TextAlignment.Right;                        break;                }

类似就不要一变又一遍的再发了。。。


[解决办法]
C# code
 TextAlignment align = TextAlignment.Left;            switch ((this.cmbStyles.SelectedValue as ComboBoxItem).Tag.ToString())            {                case "左对齐":                    align = TextAlignment.Left;                    break;                case "居中":                    align = TextAlignment.Center;                    break;                case "右对齐":                    align = TextAlignment.Right;                    break;            }            //将样式赋给富文本框的选中项            rtb_text.Selection.ApplyPropertyValue(Block.TextAlignmentProperty, align); 

热点排行