自己添加功能很容易:
1)转到命名空间
ICSharpCode.TextEditor
打开
TextAreaControl
类。文件位置是:c:…\icsharpcode.textEditor\project\src\gui\textAreaControl.cs
2)添加设置水平或垂直滚动条可见性的方法:
public void ShowScrollBars(Orientation orientation,bool isVisible)
{
if (orientation == Orientation.Vertical)
{
vScrollBar.Visible = isVisible;
}
else
{
hScrollBar.Visible = isVisible;
}
}
3)在使用文本编辑器的项目中,这是您调用
ShowScrollBars()
方法:
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical,false);
此代码根据文本行数显示垂直滚动条:
public TextEditorForm()
{
InitializeComponent();
AddNewTextEditor("New file");
SetSyntaxHighlighting("Mathematica");
editor.ActiveTextAreaControl.TextEditorProperties.IndentationSize = 0;
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical,false);
editor.TextChanged += new EventHandler(editor_TextChanged);
}
void editor_TextChanged(object sender, EventArgs e)
{
bool isVisible = (editor.ActiveTextAreaControl.GetTotalNumberOfLines > editor.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount);
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical, isVisible);
}
在文本区域控件中:
public int GetTotalNumberOfLines()
{
return this.Document.TotalNumberOfLines;
}
PS我用这个
Code Project ICSharpCode-TextEditor
项目。