Yesterday I found out that when you need to create controls at runtime, you can use the LauyoutEngine to place the controls at the right location. I always used the TableLayoutPanel for this, but I must say, the LayoutEngine works better and I have more control now.
But I was wondering, how does this work under the hood? When is the LayoutEngine property invoked? And when is it a best practice to use the layout engine?
The LayoutEngine property is accessed/created (and cached!) in the (base) constructor of the Control. So if you want to use it, you need to subclass Control or Panel and override LayoutEngine.
Try to avoid it. Your UI component:
Maybe, if your UI component
… then by all means, give it a shot! You could get some quick results, but you’ll find yourself rewriting the layout method more than you’d like.