473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Control spacing

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
Aug 14 '08 #1
2 1035
On Wed, 13 Aug 2008 18:14:15 -0700, John B <jb******@yahoo.comwrote:
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.
What could be easier than getting an exact measurement of where the text
is and calculating its position based on that?

Actually, I should point out that for text display in Forms, you really
want TextRenderer.MeasureText(), because if I recall correctly
TextRenderer is what the Forms controls use to display text. Getting
exactly correct measurements can be tricky, because there's a lot of
formatting options. :) But assuming you get it right, it should give you
exactly the information you want (assuming you really want "the exact
coordinates of the text within a label/checkbox/whatever").

Pete
Aug 14 '08 #2
Peter Duniho wrote:
On Wed, 13 Aug 2008 18:14:15 -0700, John B <jb******@yahoo.comwrote:
>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.

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
Aug 14 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hal Vaughan | last post by:
I'm testing a GUI app on a couple Linux boxen and one Win2k box. I'm using Java 1.4.2 on each (or the closest on Win2k -- whatever version comes close). On one Linux box and the Win2k box the...
12
by: Rick DeBay | last post by:
I'm trying to create a layout table, where the spacing between rows varies. I've tried using setting margin-top and border-top for the rows I wan't spaced down from the one above, and I've also...
7
by: Danny | last post by:
I have a small <div> element which contains two text blocks - one within <h5> tags and the other within <p> tags. I don't want any extra line spacing between elements so use the display:inline...
4
by: fleemo17 | last post by:
Is there a way to tweak the spacing of lines of text (or leading) *specifically* in IE6? I've created a "Quick Search" box in my layout which renders pretty consistently in all the browsers I've...
12
by: Sebastien B. | last post by:
I'm wondering if it's at all possible to have spacing between a table's cells, and only between the cells, not between the outter cells and the table's border. See end of message for an example...
38
by: Charles Law | last post by:
Am I going mad, or is there no control in .NET that will allow me to display a simple graph of a series of points held in an array? Please tell me I'm wrong. Charles
4
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any...
28
by: richardlang | last post by:
Anyone out there ever come across a preprocessor macro that compares an argument value against the predefined __DATE__ macro in order to control conditional compilation based on date. Something...
10
by: phil-news-nospam | last post by:
I have a table with 3 columns in 1 row. I want to increase the spacing _between_ the columns (gutter) _without_ increasing the spacing between those columns and the table itself. Is there a way...
1
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.