简体   繁体   中英

C# Window Forms, what a Custom Layout should return on his LayoutEngine#Layout method

I recently started with Window Forms, I'm implementing a custom layout engine and I find myself wondering about what should I return for the LayoutEngine#Layout method.

Here I've found an answer, though I'm not sure of the implications and what I should do in my concrete implementation.

(a) If "true" is returned, does this mean that a LayoutEvent is triggered on all parent's children?

(b) Why the above article suggests that in some case it may be wise to return the parent's AutoSize property?

Feel free to add any pointer that may be valuable for understanding how layout works in Window Forms.

PS The layout engine I need to implement is sort of a FlowLayout with size and alignment constraints (somehow similar to a Java's Swing BoxLayout, if that helps).

The documentation for Layout is quite specific (emphasis added):

Return true if your layout engine logic determines that layout should be performed again by the parent of the container. This might occur, for example, when the layout engine resizes child controls and determines that the container must be increased in size to accommodate the new layout.

More generally, there's a (rather old) article on MSDN: Providing Custom Layout Engines for Windows Forms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM