0

I am trying to build a grid of companies generated from my database.

I set my flowlayout as topdown. Is it possible to put a line between rows like this http://data.worldbank.org/country

If needed, my code posted below.

    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);
        }
    }
Jake Mogra
  • 51
  • 9
  • Possible duplicate of [Adjusting spacing between usercontrols in a flowLayoutPanel](http://stackoverflow.com/questions/11330734/adjusting-spacing-between-usercontrols-in-a-flowlayoutpanel) – user6807975 Mar 13 '17 at 12:15

1 Answers1

1

One solution is to use a Label to act as a line. Set AutoSize to False, Height to 1, and BorderStyle to FixedSingle. Then set the Width to the same as the FlowLayoutPanel.

Something like:

    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);
        }
    }
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40