Console.SetWindowPosition in C# not working??

fireman

Newcomer
Joined
Nov 21, 2009
Messages
5
I'm working with a basic console application. I'm trying to use the Console.SetWindowPosition method to put the console window at the top left of the screen, but for some reason its not working (and no error either).

(I also set the console to the largest size possible, as you can see in my code)

Here's my code:

Code:
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            Console.SetWindowPosition(Console.WindowLeft, Console.WindowTop);
...etc etc...

I also tried
Code:
Console.SetWindowPosition(0, 0);
but with no cigar.

Any help would be greatly appreciated.
 
SetWindowPosition, along with WindowLeft and WindowTop, specify the location of the "view window" within the console's buffer. In other words, this seems to deal with scrolling within the console, and not the actual window on the desktop.

As far as I can see, the console class does not provide what you are looking for. This code project article appears to address this need, among many others.
 
Back
Top