[英]How do i add lines/strings to richTextBox1?
ListsExtractions.text1
contain 49 items But in the end richTextbox1
is empty. ListsExtractions.text1
包含49个项目,但最后richTextbox1
为空。 How can i add the strings/lines from ListsExtractions.text1
to the 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
contain 49 items But in the end richTextbox1
is empty. ListsExtractions.text1
包含49个项目,但最后richTextbox1
为空。
Change this 改变这个
for (int i = 0; i < ListsExtractions.text1.Count; i++)
{
richTextBox1.Text = ListsExtractions.text1[i];
}
to this 对此
richTextBox1.Text = String.Join(Environment.NewLine, ListsExtractions.text1 );
I think you are calling it twice , move from constructor to the load event your code: 我想您两次调用过它,将代码从构造函数移到load事件:
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 );
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.