I am doing a TCP server & client communication. I would like to display the received data (from client) on the textbox of the server.

When i used txtStatus.AppendText, it works perfectly fine. But when i changed to txtStatus.Text, nothing was shown in the textbox.

I have tried using

txtStatus.Text += recMovementData.BaseMoveData.BaseMov.ToString();

but to no avail. :-(

It should work as it is the same as .AppendText but it doesnt :(

Can anyone help me with this?

This is my code for my server:

private void btnListen_Click(object sender, EventArgs e)
        {

            //IPAddress ipaddress = IPAddress.Parse(txtIP1.Text + "." + txtIP2.Text + "." + txtIP3.Text + "." + txtIP4.Text);
            //int portNum = Convert.ToInt32(txtPort.Text);
            IPAddress ipaddress = new IPAddress(new byte[] { 123, 123, 123, 123 });
            int portNum = 8500;
            TCPServerHelper.AcceptConnection(ipaddress, portNum);
            txtStatus.Text = "Connected to remote client!";

            while (true)
            {
                    byte[] bufferReceivedData = TCPServerHelper.Read();
                    MovementData recMovementData = (MovementData)TCPServerHelper.Deserialize(bufferReceivedData);

                    try
                    {
                        //txtStatus.AppendText(recMovementData.BaseMoveData.BaseMov.ToString());
                        txtStatus.Text += recMovementData.BaseMoveData.BaseMov.ToString();
                    }

                    catch
                    { }
         }

Have you tried adding txtStatus.Refresh(); after txtStatus.Text += ...?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.