很帅很低调 2017-08-30 11:04 采纳率: 50%
浏览 774

在一个页面生成控件,我输入7个控件,让它一行五个,剩下的两个为一行怎么做?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WFInfo.Info.Class
{
public class InfoClass
{

    public string InfoName { get; set; }  //页面名字
    public string ConType { get; set; }//控件类型
    public string ConValue { get; set; }//控件的默认值
    public int ConIndex { get; set; }//控件的索引
    public string ConDesc { get; set; }//控件描述
    public string CFName { get; set; }//控件名称
}

}

//在页面中添加控件
private void Contrl_Load(object sender, EventArgs e)
{
this.Name = ic.InfoName;
this.Text = ic.InfoName;
for (int i = 0; i < ic.ConIndex; i++)
{
Label lb = new Label();
lb.Visible = true;
lb.Text = ic.ConValue;
lb.Width = 50;
lb.Location = new Point(20 * i, 24);
panel1.Controls.Add(lb);

            TextBox tb = new TextBox();
            tb.Visible = true;
            tb.Text = ic.ConValue;
            tb.Name = ic.CFName;
            tb.Width = 100;
            tb.Location = new Point(20 * i + tb.Width * i, 24);
            panel1.Controls.Add(tb);
        }
    }

图片说明

小弟只能把它弄成一行五行,剩下的两个为一行,求哪位大神帮帮忙,感谢!!!

  • 写回答

2条回答

  • 老知了-米芾 2017-08-30 14:58
    关注

    再套一层 循环,最大索引值 4.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog