Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Remove row from tablelayoutpanel

Remove row from tablelayoutpanel

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    waddie1
    wrote on last edited by
    #1

    Hey all I have a TableLayoutPanel on a form, this form is inherited a number of times by others. This works fine but some of these forms do not need all the rows that are on the default table. I can't see any way of removing a particular row from the layout (ie row 3) on the new forms load. Can this actually be done at run time? It just seems wrong if you can't... Thanks in advance.

    J 1 Reply Last reply
    0
    • W waddie1

      Hey all I have a TableLayoutPanel on a form, this form is inherited a number of times by others. This works fine but some of these forms do not need all the rows that are on the default table. I can't see any way of removing a particular row from the layout (ie row 3) on the new forms load. Can this actually be done at run time? It just seems wrong if you can't... Thanks in advance.

      J Offline
      J Offline
      joon vh
      wrote on last edited by
      #2

      found this solution on the Scripts, by Losweg

      Hi,

      I was struggling with the same problem today.
      In the first column of my TableLayoutPanel, I'm showing a checkbox.
      When the user is checking it, a new row needs to be created.
      When the user is unchecking it, the row containing the checkbox should be
      removed.

      Logically to remove a row in the TableLayoutPanel, I would think to do
      something like this:
      tableLayoutPanel.RowStyles.RemoveAt(index);

      But I found out this is not enough.
      You need to clear the controls for that given row as well!
      tableLayoutPanel.Controls.RemoveAt(...);
      tableLayoutPanel.Controls.RemoveAt(...);

      Once the controls in the Controls-collection are gone, the Event that
      redraws your tableLayoutPanel doesn't draw them again.

      Hopes this is working for you as well...


      Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

      W 1 Reply Last reply
      0
      • J joon vh

        found this solution on the Scripts, by Losweg

        Hi,

        I was struggling with the same problem today.
        In the first column of my TableLayoutPanel, I'm showing a checkbox.
        When the user is checking it, a new row needs to be created.
        When the user is unchecking it, the row containing the checkbox should be
        removed.

        Logically to remove a row in the TableLayoutPanel, I would think to do
        something like this:
        tableLayoutPanel.RowStyles.RemoveAt(index);

        But I found out this is not enough.
        You need to clear the controls for that given row as well!
        tableLayoutPanel.Controls.RemoveAt(...);
        tableLayoutPanel.Controls.RemoveAt(...);

        Once the controls in the Controls-collection are gone, the Event that
        redraws your tableLayoutPanel doesn't draw them again.

        Hopes this is working for you as well...


        Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

        W Offline
        W Offline
        waddie1
        wrote on last edited by
        #3

        Cheers that worked, still a bit of a gap but between rows that are still remaining but it's better than having unused controls. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups