Search code examples
c#winformsuser-controls.net-2.0tablelayoutpanel

Resizable table layout panel in c#


I find the table layout panel in c# (.net 2.0) to be very primitive. I wanted to allow my users to resize the columns in a table layout panel but there are no ready made options to do so. Is there a way atleast to find out whether the cursor is directly over any borders of a cell and if so, which cell is beneath it ?? May be having this information, we can atleast try resizing that row/column thru' code. Help me finding,

  • whether the cursor is directly over any borders of a cell
  • which cell is beneath it (applicable only if the first question has an answer)

Many Thanks,

Sudarsan Srinivasan


Solution

  • If your layout is not overly complex, maybe you can achieve what you want by using SplitContainer controls? Unfortunately, each SplitContainer will have only two "cells", but you can embed a SplitContainer in another SplitContiner panel to get more resizable cells:

    ┌──────────────────┐
    │┌─────┬──────────┐│
    ││     │          ││
    ││     │          ││
    │└─────┴──────────┘│
    ├──────────────────┤
    │┌──────────┬─────┐│
    ││          │     ││
    ││          │     ││
    │└──────────┴─────┘│
    └──────────────────┘
    

    OK, so ASCII art was never one of my stronger skills, but I think you get the point ;o)