Question

With all the properties for TableLayoutPanel, I don't know why this can't be simple.

I have a tableLayoutPanel with two columns. I am trying to place a label inside the first columns to use it as the heading. I want to place it in a specific coordinates relative to the column, but I don't know how except to use the margins or padding properties. There is gotta be a simpler way than that. I have tried using the anchor and dock properties but no avail.

Can someone show me an example of how this can be done? Why can't I just drag the label to where I want it to be?

Was it helpful?

Solution

In TableLayoutPanel you can only put a single control in any cell, and the control will be placed at the top-left corner of the cell. As you've found, one of the options is to set the control's Margin property.

Another option is to put a Panel inside the cell, dock it to fill the cell, and place other controls inside the panel. This way you have full control over the placement of the control.

This increases the levels of hierarchy of controls, but that's not a problem unless it reaches to about 10 levels of nesting. That's when you may start encoutering slowness in resizing the form, or even some strange behaviour.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top