如何将换行符(\n)放入列表框 .selected 项?在这里,我有生成所有链接的代码,但我想在列表框中包含所有这些链接,这些代码正在工作,但链接没有出现在新行中,所有链接都在单行中,我的代码是:
var links = TextBox1.Text.Split(new string[] { "\n", "\r" },
StringSplitOptions.RemoveEmptyEntries);
foreach (var link in links)
{
if (!IsLinkWorking(link))
{
//Here you can show the error. You don't specify how you want to show it.
TextBox2.ForeColor = System.Drawing.Color.Green;
TextBox2.Text += string.Format("{0}\nNot working\n\n ", link);
//ListBox1.SelectedItem+= string.Format("{0}\nNot working\n\n ", link);
}
else
{
// ListBox1.SelectedValue += string.Format("{0}\nNot working\n\n ", link);
TextBox2.Text += string.Format("{0}\n working\n\n", link);
}
string[] values = TextBox2.Text.Split(',');
foreach (string value in values)
{
if (value.Trim() == "")
continue;
ListBox1.Items.Add(value.Trim());
}
}
}