ListsExtractions.text1
包含49个项目
但最终richTextbox1
是空的。
如何将ListsExtractions.text1
中的字符串/行添加到richTextBox1
?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ScrollLabelTest
{
public partial class DisplayLockedThreads : Form
{
public DisplayLockedThreads()
{
InitializeComponent();
for (int i = 0; i < ListsExtractions.text1.Count; i++)
{
richTextBox1.Text = ListsExtractions.text1[i];
}
}
private void DisplayLockedThreads_Load(object sender, EventArgs e)
{
}
}
}
ListsExtractions.text1
包含49个项目
但最后richTextbox1
是空的。
答案 0 :(得分:3)
更改此
for (int i = 0; i < ListsExtractions.text1.Count; i++)
{
richTextBox1.Text = ListsExtractions.text1[i];
}
到这个
richTextBox1.Text = String.Join(Environment.NewLine, ListsExtractions.text1 );
答案 1 :(得分:1)
我认为你是两次调用它,从构造函数移动到你的代码的加载事件:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ScrollLabelTest
{
public partial class DisplayLockedThreads : Form
{
public DisplayLockedThreads()
{
InitializeComponent();
}
private void DisplayLockedThreads_Load(object sender, EventArgs e)
{
richTextBox1.Text = String.Join(Environment.NewLine, ListsExtractions.text1 );
}
}
}