Q: How To print Space Between Control Creation at Run Time? I am creating Label controls at runtime in a loop but there is no space between them.
How would I put some space in between? My code is:
  for (int m = 0; m < dtGroupedByDate.Rows.Count; m++)
  {
      Label Date = new Label();
      Date.Text = dtGroupedByDate.Rows[m][0].ToString();
      this.Controls.Add(Date);
      Label PowerSum = new Label();
      PowerSum.Text = dtGroupedByDate.Rows[m][1].ToString();
      this.Controls.Add(PowerSum);                       
  }

Hope for your reply!

A: this.Controls.Add(new LiteralControl("&nbsp;"));

this line goes between those two adds

A: I would do this using CSS.
I don't know the format of your document, but a Label control in ASP.NET renders either as a span or, if AssociatedControlID is set, a label.  So, at a basic level something like:
span, label { margin-right: 10px; }

This would change all spans and labels, so if possible you should constrain it by specifying the container in the selector.

A: Use positioning
for (int m = 0; m < dtGroupedByDate.Rows.Count; m++)
{
   Label Date = new Label();
   Date.Text = dtGroupedByDate.Rows[m][0].ToString();
   Date.Style["margin-left"] = (m > 0) ? "20px" : "0px";
   this.Controls.Add(Date);
   Label PowerSum = new Label();
   PowerSum.Text = dtGroupedByDate.Rows[m][1].ToString();
   PowerSum.Style["margin-left"] = "20px";
   this.Controls.Add(PowerSum);
}

this answers ur question. however for a better formatting,  in a case u dont want to display all ur labels in a single row,  use style["margin-top"]. the final outcome depends on the positioning u are using (i.e. "absolute", "relative",...). so first thing i suggest is read a bit more about positioning.

A:  Dim fnt As New Font("Verdana", 8, FontStyle.Bold, GraphicsUnit.Point)
        Dim i, x, y As Integer
        x = 30
        y = 25
        i = 0
        For i = 0 To dt1.Rows.Count - 1
            Dim chk As New CheckBox()
            chk.Text = dt1.Rows(i)(0)
            chk.Location = New Point(x, y)
            chk.Font = fnt
            chk.Width = 450
            chk.ForeColor = Color.White

            Me.Panel1.Controls.Add(chk)

hope you will convert it into c# :)
I have use this code recently
