背景: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.此Richtextbox
用于背景透明度目的
答案 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;