Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:04:43+00:00 2026-06-03T16:04:43+00:00

I am trying to draw a box in a console but I cant figure

  • 0

I am trying to draw a box in a console but I cant figure out to do it without entering a new line.

I make something like this:

-----
|   |
_____

But the input line comes directly underneath it and removing the upper row of the box.

I tried with Console.setCursorPosition but the last line is already filled thus already a new line created.

How can I prevent the new line from being created?

Thanks in advance

Edit
It is possible to use the console window as a canvas?
Lets assume a window with the following size

Height : 50
Width : 100

I can place any character on any of the tiles within the above given console size.

Would this be possible if so how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:04:45+00:00Added an answer on June 3, 2026 at 4:04 pm

    It would be helpful if you posted code you wrote to create this box from ASCII chars.

    If you use Console.WriteLine(), just use Console.Write() method for the last line instead. So, for the box in your question the code can look like:

    ...
    Console.WriteLine("-----");
    Console.WriteLine("|   |");
    Console.Write("-----");
    ...
    

    Let me know if this helps.

    I made a test in a sample application and the extra line seems not to be created.

    Update

    If you want to use the box a border to the Console window, I suppose it would be the easiest solution (if not the only one) not to add the last – character in the bottom line of the box you are drawing.

    Update II

    You can try to use a simple trick and dynamically change height of the console window before drawing the last line. This will prevent the window from being scrolled.

    Try code like this:

    int width = Console.WindowWidth;
    int height = Console.WindowHeight;
    int i, j;
    for (i = 0; i < width; ++i)
    {
        Console.Write("-");
    }
    
    for (j = 0; j < height - 2; ++j)
    {
        Console.Write("|");
    
        for (i = 0; i < width - 2; ++i)
        {
            Console.Write(" ");
        }
    
        Console.Write("|");
    }
    
    //enlarge window in order to prevent it from being scrolled
    Console.WindowHeight += 1;
    
    for (i = 0; i < width; ++i)
    {
        Console.Write("-");
    }
    //restore window's original size
    Console.WindowHeight -= 1;
    //set cursor inside the border
    Console.SetCursorPosition(1, 1);
    

    This should allow you to get the whole border visible in the window.

    Update III

    The suggested solution

    Use the code above, but with Console.BufferWidth instead of Console.WindowHeight. It seems to work correctly and does not require to modify window’s dimensions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how the books draw a box perhaps with different
I'm just trying to draw a line with JavaScript. I would like it to
I'm trying to figure out how to draw graphics in XNA, and someone else
I am trying to draw a line using the Graphics 2D but then the
I am trying to draw a line along with mouse move on a paper.
I am trying to draw a picture to the window but it is only
I'm trying to draw a simple box in my iPhone game. Here is the
I'm trying to draw a horizontal line across my diagram. The Y coordinate of
So I'm simply trying to make a red 10 x 10 box move vertically
I am trying to draw an overlay which will show a box and text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.