Reputation: 3
I've been tasked with creating a feedback dialogue box to work in conjunction which offers the user simple text based feedback on what operations are occurring. E.g. master switch turned on, hob 1 turned on. I got the text response to display in a multiline textbox, but can only get it to write on the first line therefore overwriting whatever was previously there before. Is there a way to get new text responses to appear on the line below any previous inputs? This is where I'm up to:
if(MasterOnOff.Checked == true)
{
FeedbackTextBox.Text = "Master Switch On";
}
if(MasterOnOff.Checked == false)
{
FeedbackTextBox.Text = "Master Switch Off";
}
Working in C# Windows Forms, any help massively appreciated!
Upvotes: 0
Views: 1317
Reputation: 1
Try adding the following line to the textbox code in the designer class:
this.textBox1.Multiline = true;
Upvotes: 0
Reputation: 96
Try
multilineTextBox.Text += "Your message" + Environment.NewLine;
it´s equal to
multilineTextBox.Text = multilineTextBox.Text + "Your message" + Environment.NewLine;
Upvotes: 1
Reputation: 3753
Instead of FeedbackTextBox.Text = "..." which replaces the text in your textbox, try to append to the end of it by using += instead:
FeedbackTextBox.Text += "Master Switch Off\n".
which is the same as
FeedbackTextBox.Text = FeedbackTextBox.Text + "Master Switch Off\n"
The \n part is just the character for new line so that it doesn't add everything as a single line.
Upvotes: 0