You can iterate through each row of the database and then set the corresponding values to the labels. You can generate the labels on the run-time and can set the locations. I have shown it in the following example:
<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CodeProject
{
public partial class Form1 : Form
{
Label rollNo_Label;
Label name_Label;
public Form1()
{
InitializeComponent();
}
int y = 31;
private void addDymanicLabels()
{
for (int i = 0; i < 10; i++)
{
this.rollNo_Label = new Label();
this.rollNo_Label.Text = "Roll #: " + i;
this.labelContainers_Panel.Controls.Add(this.rollNo_Label);
this.rollNo_Label.Location = new System.Drawing.Point(107, 36 + y);
this.name_Label = new Label();
this.name_Label.Text = "Name: "+i;
this.labelContainers_Panel.Controls.Add(this.name_Label);
this.name_Label.Location = new System.Drawing.Point(45, 36+y);
y = y + 32;
}
}
private void Form1_Load(object sender, EventArgs e)
{
addDymanicLabels();
}
}
}