In WinForms you can set the bounds of a control using SetBounds, or if you have created a user control, you can override SetBoundsCore. I was wondering, does they both do the same or are there any differences?
In WinForms you can set the bounds of a control using SetBounds , or
Share
First of all
SetBoundsis not virtual, so if you need to run some extra code when the bounds is set, your only options is to overrideSetBoundsCore.SetBoundsdoes some parameter validation, and contains the logic with regards to calling intoSetBoundsCorewith the correct size based on theBoundsSpecifiedparameter. It also makes sure not to callSetBoundsCoreunless the size actually changes.In other words,
SetBoundsCoreis the meat of the implementation, whileSetBoundsis the public entry point which contain validation and some other housekeeping logic.