C#如何在Richtextbox中选择后删除阴影(见下图)?

时间:2015-12-29 16:09:49

标签: c# visual-studio-2012

在: enter image description here 后: enter image description here

背景:Richtextbox是我在Internet上找到的控件组件,代码是

public TransparentLabel()
{
    this.SetStyle(ControlStyles.Opaque, true);
    this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
    this.TextChanged += TransparentLabel_TextChanged;
    this.VScroll += TransparentLabel_TextChanged;
}
void TransparentLabel_TextChanged(object sender, System.EventArgs e)
{
    this.ForceRefresh();
}
protected override CreateParams CreateParams
{
    get
    {
        CreateParams parms = base.CreateParams;
        parms.ExStyle |= 0x20;  // Turn on WS_EX_TRANSPARENT
        return parms;
    }
}
public void ForceRefresh()
{
    this.UpdateStyles();
}
  1. 如何通过点击框或任何地方删除选中后的阴影(突出显示文字)?
  2. 如何修改以隐藏垂直滚动条?
  3. 备注:1。向上或向下滚动时阴影消失2.此Richtextbox用于背景透明度目的

1 个答案:

答案 0 :(得分:0)

考虑到RichTextBox对WPF(System.Windows.Controls)的控制:

this.richTextBox.SelectionBrush = null; //to remove the text highlighting
this.richTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; //to remove the vertical scrollbar

相反,考虑对Windows窗体(System.Windows.Forms)的RichTextBox控件,无法更改所选文本的颜色。有关详细信息,请阅读this page

您可以用这种方式隐藏垂直滚动条(只显示水平滚动条):

this.richTextBox.ScrollBars = RichTextBoxScrollBars.Horizontal;