C# FlowLayoutPanel中的新行
我使用以下代码在FlowLayoutPanel(WinForms-c#)中动态生成控件。我想在完成内部foreach之后添加换行符。 var fullText=textBox1.TextC# FlowLayoutPanel中的新行,c#,winforms,flowlayoutpanel,C#,Winforms,Flowlayoutpanel,我使用以下代码在FlowLayoutPanel(WinForms-c#)中动态生成控件。我想在完成内部foreach之后添加换行符。 var fullText=textBox1.Text List<string> listPoints = fullText.Split('#').ToList(); foreach (var listPoint in listPoints) { if (listPoint.Con
List<string> listPoints = fullText.Split('#').ToList();
foreach (var listPoint in listPoints)
{
if (listPoint.Contains('^'))
{
var listTextboxes = listPoint.Split('^');
int textBoxCount = listTextboxes.Count();
int index = 1;
foreach (var listTextbox in listTextboxes)
{
CheckBox ck = new CheckBox();
ck.Text = listTextbox;
ck.AutoSize = true;
ck.CheckStateChanged += new EventHandler(this.CheckBox_CheckedChanged);
flowLayoutPanel1.Controls.Add(ck);
if (index < textBoxCount)
{
TextBox tb = new TextBox();
tb.AutoSize = true;
tb.TextChanged += new EventHandler(this.TextBox_TextChanged);
flowLayoutPanel1.Controls.Add(tb);
}
index++;
}
// code for New line break
}
else
{
CheckBox ck = new CheckBox();
ck.Text = listPoint;
ck.AutoSize = true;
ck.CheckStateChanged += new EventHandler(this.CheckBox_CheckedChanged);
flowLayoutPanel1.Controls.Add(ck);
flowLayoutPanel1.
}
List listPoints=fullText.Split('#').ToList();
foreach(listPoints中的变量listPoint)
{
if(listPoint.Contains('^'))
{
var listTextBox=listPoint.Split(“^”);
int textBoxCount=listextboxs.Count();
int指数=1;
foreach(listTextbox中的变量listTextbox)
{
复选框ck=新复选框();
ck.Text=listTextbox;
ck.AutoSize=true;
ck.CheckStateChanged+=新事件处理程序(this.CheckBox\u CheckedChanged);
flowLayoutPanel1.控件.添加(ck);
if(索引
使用SetFlowBreak方法:
Control lastControl = null;
if (listPoint.Contains('^')) {
var listTextboxes = listPoint.Split('^');
int textBoxCount = listTextboxes.Count();
int index = 1;
foreach (var listTextbox in listTextboxes) {
CheckBox ck = new CheckBox();
ck.Text = listTextbox;
ck.AutoSize = true;
ck.CheckStateChanged += new EventHandler(this.CheckBox_CheckedChanged);
flowLayoutPanel1.Controls.Add(ck);
if (index < textBoxCount) {
TextBox tb = new TextBox();
tb.AutoSize = true;
tb.TextChanged += new EventHandler(this.TextBox_TextChanged);
flowLayoutPanel1.Controls.Add(tb);
lastControl = tb;
} else {
lastControl = ck;
}
index++;
}
if (lastControl != null) {
flowLayoutPanel1.SetFlowBreak(lastControl, true);
}
Control lastControl=null;
if(listPoint.Contains('^')){
var listTextBox=listPoint.Split(“^”);
int textBoxCount=listextboxs.Count();
int指数=1;
foreach(listTextbox中的变量listTextbox){
复选框ck=新复选框();
ck.Text=listTextbox;
ck.AutoSize=true;
ck.CheckStateChanged+=新事件处理程序(this.CheckBox\u CheckedChanged);
flowLayoutPanel1.控件.添加(ck);
if(索引