ICSharp code.TextEditor Veritical滚动 [英] ICSharpCode.TextEditor Veritical Scrolling

查看:1152
本文介绍了ICSharp code.TextEditor Veritical滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置垂直滚动的ICSharp code.TextEditor例如,默认情况下没有垂直滚动条是可见的。而且,只有当有人类型很多线路(超出此控件的当前高度),一个垂直滚动条会自动出现。如果是的话,怎么办?

Is it possible to configure vertical scrolling in ICSharpCode.TextEditor such that by default no vertical scrollbar is visible. And that only when someone types a lot of lines (beyond current height of this control) that a vertical scrollbar appears automatically. If yes, how?

推荐答案

它很容易将自己加入的功能:

1)转到命名空间 ICSharp code.TextEditor ,然后打开 TextAreaControl 类。该文件的位置为:C:\ ICSharp code.TextEditor \项目的\ src \桂\ TextAreaControl.cs

1) Goto the namespace ICSharpCode.TextEditor and open the TextAreaControl class. The file location is: C:...\ICSharpCode.TextEditor\Project\Src\Gui\TextAreaControl.cs

2)添加一个方法来设置水平或垂直滚动​​条的可见性:

2) Add a method to set the visibility of the Horizontal or Vertical scrollbar:

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);


这code的伎俩,以显示基于文本行数垂直滚动条:


This code does the trick to show the vertical scrollbar based on the number of text lines:

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:

In the TextAreaControl:

public int GetTotalNumberOfLines()
{
    return this.Document.TotalNumberOfLines;
}

附言:我用这个 code ++项目ICSharp code-文本编辑的项目。

这篇关于ICSharp code.TextEditor Veritical滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆