Scintilla .NET editor. Position cursor at the first visible line - c#

I am using the Scintilla .NET text editor control (ScintillaNet.dll) to display SQL. I am using the following command to position the caret cursor at a given line number. In the example below, I am positioning the caret cursor at line 102 (0 based. The grid displays 1-based line numbers.)
scintilla1.GoTo.Line(102); //0 based
I'd like text in the viewport to be displayed at the top of the screen as shown below, as the first visible line
How can I identify how to do this?
Update
This looked promising:
scintilla1.Lines.FirstVisible.Number = targetLineNumber;
but after executing, scintilla1.Lines.FirstVisible.Number wasn't always equal to targetLineNumber and I don't know what is interfering with it.There are hundreds of lines following the targetLineNumber line.

Get/Set first visible line works for me https://www.scintilla.org/ScintillaDoc.html#SCI_SETFIRSTVISIBLELINE
You can keep the cursor position first (SCI_GOTOPOS) and then set the first visible line

Related

How to remove the cursor line from a C# Console Application?

I have already managed to remove the cursor itself with Console.CursorVisible = false;. However, the line that the cursor exists in still takes up space at the bottom of my program. In other words, I would like to print to my console so that it fills the entire console screen. Here's an image of how it currently looks, with the bottom row not getting filled.
Can you show what you're doing to fill up the space? The solution may just be as simple as using Console.Write() instead of Console.WriteLine() so that it doesn't automatically make a new line, which in turn shouldn't create that empty line at the bottom

Stop Visual Studio text editor from auto moving comment lines

Is there a way (or tool) to stop Visual Studio text editor (2015 or 2017) from auto moving the comment lines when pressing Ctrl+K,D or relevant key stroke (Ctrl+E,D - format entire document) ?
I would like my comments to stay at the position placed, regardless of the code position above or below.
For example, when writing a comment line starting say at col 80 as
code line
|-------- white space -------------------| //... comment ..
code line
so that it doesn't interfere with the code below or above, when pressing Ctrl+K,D the comment is shifted left to align with the surrounding code.
On the other hand, when a comment is placed following a code line, as below
|----code line ------|-- white space --| //.... 1st comment line ....
|-------white space ---------------------| //.... 2nd comment line....
an eventual 2nd comment line remains aligned with the above one, which indicates that the editor can adjust the position of comment lines based on certain criteria
Edit: I should clarify that I would like to preserve the rest of the functionality of Ctrl+K,D

Get the position of the GanttPresenterSplitter in a <telerik:RadGanttView>

I am working on a WPF application using Telerik and coded in C# .NET.
My following question goes over a XAML page using the model “Code behind” to implement the logic of the page.
I would like to get the position of the GanttPresenterSplitter in a telerik:RadGanttView.
This information would allow me to set the position of another element in another part of the same screen.
I would also know if it is possible to add an event handler on that GanttPresenterSplitter in order to get its position each time that line moves.
The ASP .NET page is split into 3 parts (please find in attachment draft_screen) :
Red square : telerik:RadGanttView
Green square : telerik:RadGridView
Blue square : telerik:RadScheduleView
As you can see, there is a dividing line between telerik:RadGridView and telerik:RadScheduleView.
I would like that line moves at the same time and same position as the GanttPresenterSplitter in the RadGanttView.
Using a more explicit picture based on an example (please find in attachment explicit_screen) :
Orange line : GanttPresenterSpliter
Purple line : GridSplitter
My point is to coordinate the orange and the purple lines in order they have the same position all the time.
Any help will be much appreciated :)
There is no straightforward way to get the position of the GanttPresenterSplitter, however, you could, for example, get the Width of the Grid area of the GanttView, and more specifically the width of the visible area. It is presented by a ScrollBar element, so you could subscribe to its SizeChanged event to handle when the Grid area is resized.
I have prepared a sample example to demonstrate the approach, please download the attachment and give it a try.

How can I add a straight line on my chart on the basis of user input from drop down menu in asp.net c#

I have generated a chart in asp.net c#, which gets user data from the database and display it. Now I want to add a line to it which can indicate the baseline set by the user. I think it might be a new series which will be drawn from start to end. It will be ideal if the user is able to change it and on changing the line is redrawn. I have dates on x-axis and activity time on y axis. In the following picture I want line like Goal. Any suggestions?
There are two ways I know which can be used to achieve this line.
One is by adding the tag but the line will appear under the bars.
If you want the line to appear above the bars then you need to add another series of type line chart. Make its x axis secondary and specify the values so that it appears as a straight line. Hide the lengends and labels etc for line chart.

Counting lines displayed by richtextbox in C#

In my project I want to count lines displayed by richtextbox in C# with word wrap property set true. For example, in richtextbox, I write a text, and when text reaches the width of the richtextbox, then it automatically goes to second line. So what happens is the text contains actually one line but it is displayed in two lines. So I want to know how can I count this as two lines instead of one? Help will be really appreciated.
You may go for RichTextBox.GetLineFromCharIndex Method
Retrieves the line number from the
specified character position within
the text of the RichTextBox control. If WordWrap is set to false, no portion of the line wraps to the next, and the method returns 0 for the specified character index.
Also, check out this link.

Categories