I'm creating a prototype for a piece of functionality that I will be implementing in an application, specifically I am displaying data from a collection to the console window but unfortunately some of the lines span wider than the default width of the console window.
I've done a bit of digging and found that the only way to increase the width of the window is to dig into the Kernel32.dll and do it manually.
As elegant as pInvoke is, does a "shorter" way exist to increase the width e.g. (Console.Width = 300) or is using the Kernel32.dll the only way.
Thanks!
No programming is required. Create a shortcut to your program on the desktop. Right-click it, Properties, Layout tab. Adjust the Width property of the screen buffer and window size.
But you can do it programmatically too, those Windows API functions you found are wrapped by the Console class as well. For example:
static void Main(string[] args) {
Console.BufferWidth = 100;
Console.SetWindowSize(Console.BufferWidth, 25);
Console.ReadLine();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With