I have a custom UserControl which draws text and graphics using GDI+. Normally I dock it using DockStyle.Bottom within another control.
The size of this control is determined by a custom layout using Graphics.MeasureString(). Therefore, it needs to recalculate the height everytime the width changes, which is changed when the parent width changes.
Currently I am setting this control's height in its OnSizeChanged event. However I am noticing some bugs with this. Sometimes when I resize the parent, the control is not touching the bottom of the parent, even though it is set to DockStyle.Bottom. I used Spy++ to analyze the control bounds and there is simply some empty space between the control and the edge of the parent by about 20 pixels.
I want to implement a proper AutoSize in this UserControl assuming a Top or Bottom DockStyle.