I am trying to locate either a sample routine for or to at least
acquire the knowledge of how to determine how large of a window to
create to hold a text string. From my search so far, it would seem
that this is a common request, but I have yet to come across an
example solution.
I have a situation in which I need to size a window accurately, or
either I have to guess what the largest the window could ever be and
set it to a flat number. Really don't want to do this, therefore I'm
in search of a way to determine, given a string, a font, and a window
width, how high the window would need to be to hold the string.
Thank you for any pointers,
-Neil K. 3 1173
Hi Neil,
You can determine the size of a String using a given font and Graphics
control using Graphics.MeasureString or Graphics.MeasureCharacterRanges.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Neil Kiser" <neil@SPAM_GUARD_REMOVE_TESTkiservilletest.com> wrote in
message news:dn********************************@4ax.com... I am trying to locate either a sample routine for or to at least acquire the knowledge of how to determine how large of a window to create to hold a text string. From my search so far, it would seem that this is a common request, but I have yet to come across an example solution.
I have a situation in which I need to size a window accurately, or either I have to guess what the largest the window could ever be and set it to a flat number. Really don't want to do this, therefore I'm in search of a way to determine, given a string, a font, and a window width, how high the window would need to be to hold the string.
I don't know if there's a ".NET way" to do this, but you could probably use
the DrawText API function with the DT_CALCRECT option.
Chris Jobson
Hi Neil,
Graphics.MeasureString is the what you need.
You can provide enough info to that method (e.g text wrap, alignment, etc)
to get the size of your window.
The code should be pretty straightforward.
--
Stoitcho Goutsev (100) [C# MVP]
"Neil Kiser" <neil@SPAM_GUARD_REMOVE_TESTkiservilletest.com> wrote in
message news:dn********************************@4ax.com... I am trying to locate either a sample routine for or to at least acquire the knowledge of how to determine how large of a window to create to hold a text string. From my search so far, it would seem that this is a common request, but I have yet to come across an example solution.
I have a situation in which I need to size a window accurately, or either I have to guess what the largest the window could ever be and set it to a flat number. Really don't want to do this, therefore I'm in search of a way to determine, given a string, a font, and a window width, how high the window would need to be to hold the string.
Thank you for any pointers, -Neil K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter |
last post by:
Hi at all,
how can I do to make a css file to change automatically the text size of the
text that is into a table relatively the screen size?
I.E. if the screen is 800 x I want the text...
|
by: Roger Withnell |
last post by:
I open a new window from the current window to display maps.
Several maps of different sizes can be displayed. The function is given the
size of the map and adjusts the window size accordingly....
|
by: Yeah |
last post by:
Ever since I upgraded my Windows display to 120 DPI (kind of a necessary
change), fonts have been clearer and graphics have been crisper. However,
the 25% automatic increase in the text size on my...
|
by: littlealex |
last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS!
In IE6 the text for the following page doesn't display properly - rather than being...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |