Hey,
I would like to set the position of the cursor in the Console to the last visible line. How can I do this?
Cheers,
Pete
Hey,
I would like to set the position of the cursor in the Console to the last visible line. How can I do this?
Cheers,
Pete
If you mean the last line of the window, you can use a mixture of Console.CursorTop
, and Console.WindowHeight
and Console.WindowTop
. Sample code:
using System;
class Test
{
static void Main()
{
Console.Write("Hello");
WriteOnBottomLine("Bottom!");
Console.WriteLine(" there");
}
static void WriteOnBottomLine(string text)
{
int x = Console.CursorLeft;
int y = Console.CursorTop;
Console.CursorTop = Console.WindowTop + Console.WindowHeight - 1;
Console.Write(text);
// Restore previous position
Console.SetCursorPosition(x, y);
}
}
Note that this has to take account of Console.WindowTop
to find out where you are within the buffer...