Elliot678
Elliot678

Reputation: 348

When I output a string into a checked list box in windows forms only the first line of the string is shown next to the checkbox

When I click the button method below

private void button1_Click(object sender, EventArgs e)
    {
        string output;

        //Concatenate the text value of the 3 text boxes
        output = "Task: " + this.textBoxTask.Text + "\r\n";
        output += "Description: " + this.textBoxDescription.Text + "\r\n";
        output += "Due Date: " + this.textBoxDueDate.Text + "\r\n";

        this.checkedListBoxTasks.Items.Add(output);

    }

On the line 'Task: whatever i wrote in the textbox' is shown next to the checkbox is there anyway to make it show the other two lines?

Upvotes: 0

Views: 220

Answers (2)

Roy
Roy

Reputation: 81

Try this one.

this.checkedListBoxTasks.Items.Add(this.textBoxTask.Text);
this.checkedListBoxTasks.Items.Add(this.textBoxDescription.Text);
this.checkedListBoxTasks.Items.Add(this.textBoxDueDate.Text);

Hope this help you. :D

Upvotes: 2

Nudier Mena
Nudier Mena

Reputation: 3274

Try to use the StringBuilder Class in the System.Text namespace for string concatening.

Upvotes: -1

Related Questions