title: TableLayoutPanel: Delete Rows
body: <p>I have a TableLayoutPanel which is filled with rows at runtime using a text file (get each row from the text file, and put it in cells contained in new rows).
  Code Looks like this:</p>
  
  <pre><code>public static string UrlList= @"C:\Users\Berisha\Desktop\URLs.txt";
  string[] UrlRows = System.IO.File.ReadAllLines(@UrlList);
          private void InitPaths()
      {
          int a = 0;
          int c = 1;
          while (a &lt; UrlRows.Length-1)
          {   
              //new label
              var label = new Label();
              label.Dock = DockStyle.Fill;
              label.AutoSize = false;
              label.Text = UrlRows[a];
              label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
              label.Size = new System.Drawing.Size(22, 13);
              label.BackColor = System.Drawing.Color.Transparent;
              TBP.Controls.Add(label, 3, c); //Add to TableLayoutPanel
              a++;
              c++;
          }
      }
  </code></pre>
  
  <p>Although I want to be able to manually edit the source,
  so I wrote a method which would delete everything new created, but seem to be stuck here, because it doesn't work:</p>
  
  <pre><code>        private void clearPaths()
      {   
          int c = UrlRows.Length - 1;
          while (c &lt;= UrlRows.Length - 1)
          {
              TBP.RowStyles.RemoveAt(c); //Remove from TableLayoutPanel
              c--;
          }
  
      }
  </code></pre>
  
  <p><em>//The Code Stops at: TableLayoutPanel.RowStyles.RemoveAt(c);(while Debugging)
  //and the error reads : "Object reference not set to an instance of an object"</em>
  <strong>Update: I managed to get out of the Error, my Problem now, after I say RemoveAt, nothing seems to be removed</strong>
  Does anybody know what it is that I could do?</p>