Control spacing

  • Thread starter Thread starter John B
  • Start date Start date
J

John B

Does anyone know how to determine the exact coordinates of the text
within a label/checkbox/whatever?

I know I could use MeasureCharacterRanges but I think there's an easier way.
The vs designer allows snapping to the edge of the text (not the edge of
the label) and I'd like to be able to replicate that easily in code.

TIA

JB
 
Peter said:
What could be easier than getting an exact measurement of where the text
is and calculating its position based on that?
Sure, but i'd prefer to use an existing mechanism (if it exists).

Such as Control.Padding, but it is zero for all the controls i've
checked so it doesnt apply.
I'd think that the label/whatever would calculate this info once and
then cache that value until it becomes stale and then recalc and so on.
Actually, I should point out that for text display in Forms, you really
want TextRenderer.MeasureText(),
<...>

Yep, rings a bell, thanks.

Cheers,

JB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top