是否可以在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. 滚动垂直
- 2. 垂直滚动条
- 3. FlowPanel垂直滚动
- 4. 垂直滚动SIlverlight
- 5. Phonegap垂直滚动
- 6. Android - 垂直滚动?
- 7. 垂直滚动条
- 8. Android垂直滚动
- 9. SWFLoader垂直滚动
- 10. jquery垂直滚动
- 11. Div垂直滚动
- 12. Viewpager垂直滚动
- 13. 垂直viewpager垂直滚动型
- 14. 垂直Android TabLayout不垂直滚动
- 15. LWUIT水平列表滚动垂直滚动垂直窗体
- 16. 垂直自动滚动Textview
- 17. 移动和滚动垂直
- 18. 垂直滚动条动画
- 19. 滚动垂直滚动条jquery
- 20. 离子滚动不会垂直滚动
- 21. 滚动型不垂直滚动
- 22. 水平滚动和垂直滚动
- 23. 垂直滚动和水平滚动
- 24. 垂直滚动的水平滚动条
- 25. 滚动视图中的垂直滚动
- 26. 大图垂直滚动
- 27. Bootsrap垂直滚动表
- 28. 启用垂直滚动textarea
- 29. C#WPF DataGrid垂直滚动
- 30. 两个垂直滚动条
+1不再是风滚草:) – 2013-04-28 03:24:17