Thread: Delete Lines

Results 1 to 2 of 2
  1. #1
    0x01337's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    73
    My Mood
    Asleep

    Delete Lines

    With this you can delete x Lines from your C# consoleapplication.
    Its very help and useful, so you mustn't redraw anything.

    Code:
     public static void ClearLastConsoleLines(int count)
            {
                int cursorTop = Console.CursorTop;
                if ((count == cursorTop) || (count == 0))
                {
                    Console.Clear();
                }
                else if ((count < cursorTop) && (count > 0))
                {
                    string str = new string(' ', Console.WindowWidth * count);
                    Console.SetCursorPosition(0, cursorTop - count);
                    Console.Write(str);
                    Console.SetCursorPosition(0, cursorTop - count);
                }
            }

  2. #2
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,112
    My Mood
    Angelic
    Quote Originally Posted by 0x01337 View Post
    With this you can delete x Lines from your C# consoleapplication.
    Its very help and useful, so you mustn't redraw anything.

    Code:
     public static void ClearLastConsoleLines(int count)
            {
                int cursorTop = Console.CursorTop;
                if ((count == cursorTop) || (count == 0))
                {
                    Console.Clear();
                }
                else if ((count < cursorTop) && (count > 0))
                {
                    string str = new string(' ', Console.WindowWidth * count);
                    Console.SetCursorPosition(0, cursorTop - count);
                    Console.Write(str);
                    Console.SetCursorPosition(0, cursorTop - count);
                }
            }
    Nice one

    Here is one for a RichTextBox Control: (Sorry any mistakes)
    Code:
    public void LineEdit(int Line, string NewValue, bool Clear = false)
            {
                int LinesLengh = richTextBox1.Lines.Length;
                if (Line >= LinesLengh)
                    MessageBox.Show("Error - Line don't Exsist!");
                else
                {
                    string[] TempData = richTextBox1.Lines;
                    TempData[Line] = NewValue;
                    richTextBox1.Lines = TempData;
                }
                if (Clear)
                    richTextBox1.Clear();
            }
    Example usage:
    Code:
    LineEdit(1, "Wonder");

    For console usage, I think you could just replace the: richTextBox1.Lines with Console.Lines

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

Similar Threads

  1. Plz do not delete, its my hw from school!!!!!
    By Daryth22 in forum Spammers Corner
    Replies: 10
    Last Post: 03-23-2011, 12:47 PM
  2. who deleted the thread
    By kvmn8 in forum General
    Replies: 9
    Last Post: 08-15-2006, 10:39 AM
  3. Whose line is it anyways - Richard Simons
    By Dave84311 in forum General
    Replies: 2
    Last Post: 08-13-2006, 03:54 PM
  4. My post deleted?
    By Unavailable in forum General
    Replies: 3
    Last Post: 05-24-2006, 07:10 AM
  5. [Tutorial] Reading from the CMD line
    By shercipher in forum C++/C Programming
    Replies: 7
    Last Post: 04-04-2006, 12:49 PM