ICSharpCode.TextEditor Scroll Vertical

Is it possible to configure vertical scrolling in ICSharpCode.TextEditor so that by default the vertical scroll bar is not visible. And only when someone types a lot of lines (outside the current height of this control) does the vertical scroll bar appear automatically. If so, how?

+5
source share
1 answer

Easy to add function yourself:

1) Go to the namespace ICSharpCode.TextEditorand open the class TextAreaControl. File location: 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) TextEditor 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:

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

ps ICSharpCode-TextEditor.

+1

All Articles