Outputing an array to a textbox ?

This is a discussion on Outputing an array to a textbox ? within the C# Programming forums, part of the General Programming Boards category; hey all ... just wondering if someone knows how to convert an array to a textbox. I have a StreamReader ...

  1. #1
    Registered User C of Green's Avatar
    Join Date
    Jan 2002
    Location
    Calgary/Canada
    Posts
    59

    Outputing an array to a textbox ?

    hey all ... just wondering if someone knows how to convert an array to a textbox. I have a StreamReader that reads in 3200 chars, and im tring to output them into a textbox, however it will only display one char. I have tried using a for loop to copy them also, but they just overwrite the first char.


    Code:
            private void inputTextBox_KeyDown(object sender, KeyEventArgs e)
            {
                if(e.KeyCode == Keys.Enter)
                {
                    string fileName;
    
                    fileName = inputTextBox.Text;
    
                    if(File.Exists(fileName))
                    {
    
                        try
                        {
                            StreamReader stream = new StreamReader(fileName);
                            stream.ReadBlock(ASCIIHeader, 0, 3200);
                            outputFileTextBox.Text = Convert.ToString(ASCIIHeader);  // problem only outputs one char !
                        }
                        catch (IOException)
                        {
                            MessageBox.Show("Error reading from file", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }

    Thanks for any help

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Try this:
    Code:
    outputFileTextBox.Text = new string ( ASCIIHeader );
    My best code is written with the delete key.

  3. #3
    Registered User C of Green's Avatar
    Join Date
    Jan 2002
    Location
    Calgary/Canada
    Posts
    59
    Thanks, that worked great!


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  2. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21