ICSharpCode.TextEditor垂直滚动
是否可以在ICSharpCode.TextEditor中配置垂直滚动,使默认情况下不显示垂直滚动条。只有当有人输入很多行(超出此控件的当前高度)时,才会自动显示垂直滚动条。如果是,如何?ICSharpCode.TextEditor垂直滚动
它很容易添加自己的功能:
1)转到命名空间ICSharpCode.TextEditor
并打开TextAreaControl
类。该文件的位置是:C:\ ICSharpCode.TextEditor \项目的\ src \桂\ TextAreaControl.cs
2)添加一个方法来设置水平或垂直滚动条的可见性:
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);
}
在TextAreaControl:我使用这个Code Project ICSharpCode-TextEditor项目
public int GetTotalNumberOfLines()
{
return this.Document.TotalNumberOfLines;
}
PS。
也可以隐藏水平滚动条?我检查了代码和API调用,但我找不到它。 – 2014-08-07 21:00:56
我还没有在我面前打开代码,但你应该能够设置'Orientation.Vertical'到'Orientation.Horizontal' – 2014-08-08 02:28:21
谢谢,是的,我知道但我问了错误的问题,我想知道如果有一种方法可以确定一行上的列/最大字符总数,以查看是否可以基于该逻辑自动隐藏HScrollBar。 – 2014-08-08 07:02:30
+1不再是风滚草:) – 2013-04-28 03:24:17