Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 06-28-2006, 12:51 PM   #1 (permalink)
Forum Expert
 
BeneathTheStars's Avatar
 
Join Date: Jul 2005
Location: (South)Tip o' Texas
Posts: 1,294
Send a message via AIM to BeneathTheStars Send a message via MSN to BeneathTheStars
Default New textbox line.

Hello, i am having a bit of a problem with textboxes. I am trying to get it to put each message on a new line, instead of adding it to the end of one, or replacing whats there. Here is part of the code:

Code:
  
(...)
private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                tcpclnt = new TcpClient();
                SetText4("Connecting...");
                tcpclnt.Connect(textBox2.Text, 8221);
            }
            catch (Exception p)
            {
                SetText1("Connecting Error: " + p.ToString() + "");
            }
        }
private void SetText1(string text)
        {

            if (this.textBox1.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText1);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.textBox1.Text += text;// adds to the end of the line
            }
        }
        private void SetText4(string text)
        {
            if (this.textBox4.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText4);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.textBox4.Text = text;//replaces whats there
            }
        }
        private void SetText5(string text)
        {
            if (this.textBox5.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText5);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.textBox5.Text = text;
            }
        }
(...)

Any insight would be fantastic.
BeneathTheStars is offline   Reply With Quote
Old 06-28-2006, 01:03 PM   #2 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hic sunt leones ...
Age: 21
Posts: 1,289
Send a message via MSN to arul
Default

try adding a new line character '\n' at the beginning of each message ( or at the end of the previous one ) that you want to be put on a single line.
__________________
Angels are falling the very last time, down they're burning in hate and decline, unfaithful and violent we're breaking the spell, we're god, we're scissor, in heaven and hell!
arul is offline   Reply With Quote
Old 06-28-2006, 01:21 PM   #3 (permalink)
Forum Expert
 
BeneathTheStars's Avatar
 
Join Date: Jul 2005
Location: (South)Tip o' Texas
Posts: 1,294
Send a message via AIM to BeneathTheStars Send a message via MSN to BeneathTheStars
Default

Doing this:
Code:
\r\n
Worked. Thx!

Last edited by BeneathTheStars; 06-28-2006 at 01:23 PM.
BeneathTheStars is offline   Reply With Quote
Old 06-28-2006, 02:57 PM   #4 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 28
Posts: 4,886
Default

incase you cared, i believe textbox.Append( text ); works too
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5