473,507 Members | 5,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawstring Text width

I am just getting into the area of printing and I am trying to determine the
maximum drawing width that a text field of 25 characters will take up so I
can right align the next field. Is there something comparable to the
textwidth method of vb 6 that will give me this information?

Thanks
Nov 20 '05 #1
4 8062
Will Graphics.MeasureString method give you what you want?

"Cliff Lane" <C_*******@email.msn.com> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
I am just getting into the area of printing and I am trying to determine
the
maximum drawing width that a text field of 25 characters will take up so
I
can right align the next field. Is there something comparable to the
textwidth method of vb 6 that will give me this information?

Thanks

Nov 20 '05 #2
Hi,

Take a look at the graphics.measurestring method.

http://msdn.microsoft.com/library/de...tringtopic.asp

Ken
-------------------
"Cliff Lane" <C_*******@email.msn.com> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
I am just getting into the area of printing and I am trying to determine
the
maximum drawing width that a text field of 25 characters will take up so
I
can right align the next field. Is there something comparable to the
textwidth method of vb 6 that will give me this information?

Thanks

Nov 20 '05 #3
* "Cliff Lane" <C_*******@email.msn.com> scripsit:
I am just getting into the area of printing and I am trying to determine the
maximum drawing width that a text field of 25 characters will take up so I
can right align the next field. Is there something comparable to the
textwidth method of vb 6 that will give me this information?


'Graphics.MeasureString':

<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdrawinggraphicsclassmeasurestringtopic. asp>

\\\
Dim g As Graphics = Label1.CreateGraphics()
Dim s As SizeF = _
g.MeasureString(Label1.Text, Label1.Font, Label1.Width, StringFormat.GenericTypographic)
g.Dispose()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
* "Cliff Lane" <C_*******@email.msn.com> scripsit:
I am just getting into the area of printing and I am trying to determine the
maximum drawing width that a text field of 25 characters will take up so I
can right align the next field. Is there something comparable to the
textwidth method of vb 6 that will give me this information?


Have a look at 'e.Graphics' in the 'PrintDocument''s 'PrintPage' event
handler. You can use 'Graphics' object's 'MeasureString' method there
to get the size of the text, and you can specify the alignment in the
'DrawString' method.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

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

Similar topics

1
6044
by: timtos | last post by:
I am working on a custom treeView and have some problems with a) node.Bounds.Width b) concatenate strings drawn with DrawString(...) a) I want to highlight a selected node and used the...
1
8814
by: Drew | last post by:
I posted this to framework.drawing, but did not get any responses... Maybe here?? I am drawing some text using DrawString() and using a bounding rectangle so that when the string is too long it...
1
9340
by: John | last post by:
I'm trying to use the DrawText() method to draw some very long string text on the Panel with AutoScroll enabled. However, for some unknown reasons, I could not trigger the ScrollBar to show up. ...
6
9389
by: Sam Sungshik Kong | last post by:
Hello! I'm testing Graphics.DrawString and it's very strange. I created an event handler for the form.s Paint event. (There's no other code in the form.) private void Form1_Paint(object...
3
2037
by: Jonah Olsson | last post by:
Hi guys! I'm trying to use Swedish characters with DrawString but no luck. Do I need to set the Charset somewhere?? I've been searching Google Groups for hours now, but I can't find any help or...
1
267
by: johnb41 | last post by:
I need to print out a string of text and obviously i'm using the DrawString command. But the string must be placed AFTER some "programmatically generated text" (also printed using DrawString). ...
2
2521
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So...
0
1127
dzenanz
by: dzenanz | last post by:
Platform: VS2005/WinXP/.NET 2.0 I am trying to make one sentence of text scroll from right to left over the form (that works well enough, although not perfect). Problem is, when I try to add...
4
6139
by: Sin Jeong-hun | last post by:
Hello. It seems like the default behavior of DrawString is trying to keep the whole word if possible. I'd like the string to be drawn in multilines, but filling the entire line width. For example...
6
2664
by: Dilip | last post by:
Howdy Folks I have a display where the Graphics.DrawString function is called to display something. Since the text seems to be larger than its bounding rectangle, the call basically splits the...
0
7372
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
7029
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
5619
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,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4702
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
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
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 ...
1
758
muto222
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.