tags:

views:

295

answers:

3

Is it possible to use Console.Write to place a single character at the very bottom right of a typical 80x25 console, without having the console scroll the row up? This is the code that I'm using...

Imports System
Console.SetCursorPosition(Console.WindowWidth-1, Console.WindowHeight-1)
Console.Write("x")

This is not working like I would like it to. Any suggestions or alternatives? I've tested that SetCursorPosition does use a 0,0 coordinate system, already. Using the WindowWidth-1/Height-1 should put me in the lower right corner of the screen... which it does, but then Console.Write is putting the "x" down and continuing on to the next line.

A: 

The problem is that whenever you write to the last location in a particular line, the console always moves you to the next line. The closest thing you can do is write to the second last location:

        Console.CursorLeft = Console.WindowWidth - 1;
        Console.Write("X");
adeel825
+3  A: 

You can try moving the buffer area. For example:

Console.WriteLine("Top")
Console.SetCursorPosition(Console.WindowWidth - 1, Console.WindowHeight - 1)
Console.Write("x")
Console.MoveBufferArea(0, 0, 80, 25, 0, 1)
Console.ReadLine()
aphoria
That works perfectly. Thank you!
Valdemarick
You are welcome, glad I could help.
aphoria
A: 

I solved it in a dirty but functional way.

Console.SetCursorPosition(79, 24); //last pos
Console.BufferWidth++;
Console.Write("x");
Console.BufferWidth--;
Console.ReadKey();

the side of the box does flicker a millisecond, but I don't think anyone will ever notice :)

Marcus Medina
I know I would. And I'll bet I'm not alone.
Kawa