I’m attempting to make a custom control that properly draws itself to fill its current size. I was under the assumption that I should use the ClientRectangle property for sizing, but the right and bottom of the client rectangle seem to be getting clipped.
Filling the draw event handler with
Rectangle smaller = new Rectangle(5, 5, ClientRectangle.Width - 10, ClientRectangle.Height - 10);
e.Graphics.DrawRectangle(System.Drawing.Pens.Black, smaller);
e.Graphics.DrawRectangle(System.Drawing.Pens.Red, ClientRectangle);
yields this:

What should I be using to get the drawable area of the control?
You can either use:
where
Graphics g = e.Graphics;.Or draw it as you did but subtracting 1 from width and height (1 because width and height are inclusive but draw rectangle needs the size exclusive the last pixel – internally it calculates
x + w/y + hwhich then ends up at the position for the next pixel after the last, hence we need to subtract one to get the position for the last pixel).And of course this from within the
OnPaintevent handler.