473,472 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

.net cf 2 c# measure string height with maximum width

I can not find a way to measure the height of a string by setting a
maximum width!
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?

Feb 15 '07 #1
3 8914
C# is only used by really really really short people


On Feb 14, 5:12 pm, mrpete...@gmail.com wrote:
I can not find a way to measure the height of a string by setting a
maximum width!
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?

Feb 16 '07 #2
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?
MrPete,
in Petzold, Programming Windows in C#, Ch4,

you find something similar (you have to subclass Form):
Graphics grfx = CreateGraphics();
Sizef sizef;
float x, y =0;

sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.

I hope this helps,
Janos

Feb 16 '07 #3
On Feb 16, 3:53 am, "Janos" <jkazs...@intARTS.comwrote:
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?

MrPete,
in Petzold, Programming Windows in C#, Ch4,

you find something similar (you have to subclass Form):
Graphics grfx = CreateGraphics();
Sizef sizef;
float x, y =0;

sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.

I hope this helps,
Janos
sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.
what do I put after the "."? It always reports the same height!

Feb 17 '07 #4

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

Similar topics

7
by: Dan Jones | last post by:
Hello, I'm trying to figure out how to get bit operators to work on a binary string. This is what I'm trying to do: list(frame) #where frame is a binary string y = frame << 8 It gives me a...
0
by: Dan Jones | last post by:
Hello all, I'm writing a webcam app to display video from a video4linux device. I'm having trouble with the function to convert the video from yuv420p format to rgb. Its a C function that I...
6
by: Rob | last post by:
I need to create a form that will resize only the verticle size of the Form and not the width. So far I'm partial to the following code. Can someone please elaborate the ??? . . . . Const...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
8
by: Kentor | last post by:
Hello, I have users that submit images to my website. By default I choose to make the width bigger than the height because usually pictures are taken horizontally... But in some cases people take...
6
by: HMS Surprise | last post by:
The string s below has single and double qoutes in it. For testing I surrounded it with triple single quotes. I want to split off the portion before the first \, but my split that works with...
3
by: =?iso-8859-1?q?Jean-S=E9bastien?= | last post by:
hello, is it possible to resize an image with same proportion. having a maximum height and a maximum width. the solution should work on main browsers (do not use max-height and max-width). ...
4
by: Academia | last post by:
I need to create a Bitmap just big enough to display a string. Since I need a Graphic object to measure the string I create and dispose a Bitmap and a Graphic object only for that purpose. ...
5
by: BillE | last post by:
I am using VB.NET, VS 2005 Add a windows form and in design view: Add a Radiobutton to the windows form Set AutoSize = True for the radiobutton Set the MaximumSize width to 90 for the...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.