Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Console Window's size throws ArgumentOutOfRangeException

Tags:

I am trying to set the size of the Console Window in a c# console application. I get an ArgumentOutOfRangeException with this message:

The value must be less than the console's current maximum window size of 41 in that dimension. Note that this value depends on screen resolution and the console font.

I am using this to set it:

Console.WindowHeight = 480; 

How do you set the Console window's size properly?

like image 711
msbg Avatar asked Feb 26 '13 21:02

msbg


People also ask

How do I resize the console window?

Click on the icon on the top left of the console frame (the one that looks like "C:\"), then select Properties . This lets you customize all kinds of stuff. The "layout" tab has the width of the window.

How do I change the size of my console in C#?

SetWindowSize() Method in C# Console. SetWindowSize(Int32, Int32) Method is used to change the height and width of the console window to the specified values. Syntax: public static void SetWindowSize (int width, int height); Parameters: width: The width of the console window measured in columns.


1 Answers

From MSDN of Console.WindowHeight property:

The height of the console window measured in rows.

As you can see, these are not pixels. Just remember, these values can change depending on your screen resolution and the console font. You can find maximum height and width values with Console.LargestWindowWidth and Console.LargestWindowHeight properties.

Console.WriteLine(Console.LargestWindowHeight); Console.WriteLine(Console.LargestWindowWidth); 
like image 190
Soner Gönül Avatar answered Oct 31 '22 04:10

Soner Gönül