I am having trouble getting my chat application working correctly. I have 2 textbox’s, 1 to type what you would like to send, and another to display the conversation. For now I am trying to display what the user enters in the typeBox In the displaybox. I imagine I need an array or list of type string and add the entered text to it each time the button is pressed, then print the array/list to the displaybox. I have been trying a few approaches but I cant quite get it working correctly.
Could anyone shed some light on what approach to take ?
EDIT:
This is the code which I have so far. It is print out the array but without a line break and It fails to clear the display box each time, so I am getting duplicated of the same messages appearing.
string ArrayData = string.Empty;
ArrayList listData = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
listData.Add(entryBox.Text);
foreach (string textItem in listData)
{
ArrayData = "You >> " +ArrayData + textItem + "\n";
}
entryBox.Focus();
displayBox.Text = "";
displayBox.Refresh();
this.displayBox.Text = ArrayData;
entryBox.Text = "";
}
This is probably obvious what Is wrong here but Ive been looking at it so long I cant see it.
Cheers,
: Dan
wouldn’t appending the string in the inputbox with
\nto the string in the display box solve your problem? you do not need to save each line in an array or arraylistPseudocode