Setting scroll bar large change to optimal value

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by Matt Adamson
Avatar
Guys

I have some code such as
    hScrollBar.Maximum =    Math.Max(   leftFileSingleLineSyntaxEditor.SelectedView.HorizontalScrollBarMaximum,
                                                  rightFileSingleLineSyntaxEditor.SelectedView.HorizontalScrollBarMaximum);

                hScrollBar.LargeChange = 300;
As using a single horizontal scroll bar to scroll to editor ( single lines ) at the same time. However I would like to know how I can set the LargeChange value effectively rather than hard coding, perhaps calculating from the max no of characters horizontal in either of the two editor views.

In a specific example the Maxium property is set to 732. Obviously the default for LargeChange of 10 is too small. If all characters can be fitted into two horizontal pages then surely the size of large change should be approximately 366 in this example? If this is the case how could I calculate this better?

Comments (2)

Posted 11 years ago by Matt Adamson
Avatar
Actually I just tried this and is the best I could do
                Int32 maxCharacters = Math.Max( leftFileSingleLineSyntaxEditor.Document.Lines[0].Length,
                                                rightFileSingleLineSyntaxEditor.Document.Lines[0].Length);

                hScrollBar.LargeChange = Convert.ToInt32(Convert.ToDecimal(hScrollBar.Maximum) * (Convert.ToDecimal(leftFileSingleLineSyntaxEditor.SelectedView.VisibleColumnCount) / Convert.ToDecimal(maxCharacters)));
Thoughts please?
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We just set the large change to:
Math.Max(3, EditorView.TextAreaBounds.Width)

Where EditorView is the ref to whatever view contains the scrollbar.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 8 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.