行之间的FlowLayoutPanel行

时间:2013-07-03 15:24:00

标签: c#

我正在尝试构建从我的数据库生成的公司网格

我将flowlayout设置为topdown。是否可以在行之间添加一行,如http://data.worldbank.org/country

如果需要,我的代码发布在下面。

    public void createLinks(string[] groupNames)
    {
        for (int i = 0; i < groupNames.Length; i++)
        {
            LinkLabel obj = new LinkLabel();
            obj.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
            obj.LinkColor = Color.Black;
            obj.Name = groupNames[i];
            obj.Text = groupNames[i];
            obj.Click += delegate(object sender, EventArgs e)
            {LinkLabel ss = sender as LinkLabel;
            frmCompanyReport test = new frmCompanyReport(ss.Name);
            test.Show();
            };
            flowLayoutPanel1.Controls.Add(obj);
        }
    }

1 个答案:

答案 0 :(得分:1)

一种解决方案是使用Label作为一条线。将AutoSize设置为False,将Height设置为1,将BorderStyle设置为FixedSingle。然后将Width设置为与FlowLayoutPanel相同。

类似的东西:

    public void createLinks(string[] groupNames)
    {
        for (int i = 0; i < groupNames.Length; i++)
        {
            LinkLabel obj = new LinkLabel();
            obj.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
            obj.LinkColor = Color.Black;
            obj.Name = groupNames[i];
            obj.Text = groupNames[i];
            obj.Click += delegate(object sender, EventArgs e)
            {
                LinkLabel ss = sender as LinkLabel; 
                frmCompanyReport test = new frmCompanyReport(ss.Name);
                test.Show();
            };
            flowLayoutPanel1.Controls.Add(obj);

            Label line = new Label();
            line.AutoSize = false;
            line.BorderStyle = BorderStyle.FixedSingle;
            line.Height = 1;
            line.Width = flowLayoutPanel1.Width;
            flowLayoutPanel1.Controls.Add(line);
        }
    }