IfYouSaySo
Well-known member
More a general interest. Let's say I want to resize a Checkbox control to always be just large enough to display whatever is in Checkbox.Text. It's easy to determine the string length using Graphics.MeasureString, and it's easy to figure out what handlers to do that in. I found one example online that suggested creating a derived class from CheckBox and overriding the Paint handler to do this.
My question is, the client area is more than just the width of the Text string. It is also the width of the actual checkbox. The example I found online failed to take this into account. How do I (dynamically) calculate the width of that part?
For now, I simply added the constant 35 to the width, which is pretty close, but in the interests of being precise and correct, how would I do that?
My question is, the client area is more than just the width of the Text string. It is also the width of the actual checkbox. The example I found online failed to take this into account. How do I (dynamically) calculate the width of that part?
For now, I simply added the constant 35 to the width, which is pretty close, but in the interests of being precise and correct, how would I do that?