What is the best C# form control to display a stream of text?

Discussion in 'Trading Software' started by bungrider, Nov 17, 2003.

  1. Hi all,

    In VB6 it seemed like it was easy to spew out a bunch of numbers into a text box.

    I am *beta* testing my C# TWS API program and I want to spew out the data it's sup'd to be collecting. It's easy if you have a console app but I am not sure how to do it with a GUI???

    Is there a text box you can put on the form that will take up a lot of space and automatically <CR> the data to the next line as more comes out??

    I have this code that came out of the help section in C#.net and it spews the output of an array into the console:

    public static void PrintIndexAndValues( IEnumerable myList )
    {
    int i = 0;
    System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();
    while ( myEnumerator.MoveNext() )
    Console.WriteLine( "\t[{0}]:\t{1}", i++, myEnumerator.Current );

    }



    What I am looking for is a box (form control) that I can drag onto the form to just show the output (so I can see that it's workin' before I try to do anything with the data) just like the output of the above method is spat out to the console.



    Mucho thx in adv,
    -b
     
  2. Try:
    Code:
    System.Diagnostics.Debug.WriteLine("your text here");
    This will write text to the output window.

    Alternatively, add a listbox and use:
    Code:
    lstStatus.Items.Add("your text here");
    I hope this is what you were looking for.
     
  3. nitro

    nitro

    Use a Textbox control that comes with C#. Probably dock it somewhere. Set it's properties to readonly, to have vertical scroll bars, and to use multiline.

    Then, in your code, whenever you want to output a string, do, e.g.,

    textBox2.AppendText(string_to_output + "\r\n");

    nitro

    PS There is probably a better way to say "\r\n" in C#. In C++ it was endl, but I am not sure what the C# idiom is.
     
  4. Hey guys--

    Thanks a ton for the help.

    I am a newbie at this, and I keep getting this error when I try to compile this code-



    public static void PrintIndexAndValues( IEnumerable lastAL )
    {
    IEnumerator myEnumerator = lastAL.GetEnumerator();
    while ( myEnumerator.MoveNext() )
    {
    // textBox1.text = myEnumerator.Current.ToString();
    listBox1.Items.Add(myEnumerator.Current.ToString());
    }
    }


    I am trying to get it to spit out these array values into either a textbox or a listbox (same error when I tried the output window also) but when I compile, it stops on textBox1 or listBox1 and tells me that the word denotes a field where a class is expected.

    Any help would be much obliged.

    TIA,
    -b
     
  5. tomf

    tomf

    post the error, too
     
  6. actually decided to go another route and instead dump the array into a text file. thataway i can actually start using the data.
     
  7. ...if i can get the fucking thing to work, that is.

    hahahaha
     
  8. ahahahahahaaaaaaaaaaa! i got the fucker to work!

    it spits out info into a text file. wow...

    as for the error earlier, it was just like i said -- "it stops on textBox1 or listBox1 and tells me that the word denotes a field where a class is expected."

    for some reason, it would only take class.method in this while block --

    while ( myEnumerator.MoveNext() )
    {
    Class.Method();
    }



    ...putting in anything about a textbox, listbox, etc. in place of the above Class.Method() only gave me the compiler error mentioned above...
     
  9. Maybe because while you were in the while block, you were outside of the scope of the where the list box or text box (or whatever) was alive. Just guessing out loud.
     
  10. (BTW - congrats on your text box success!)
     
    #10     Nov 18, 2003