Hi, please excuse this, my third posting today. It is my last I
promise.
When I past this into form1, I am expecting to see
"Start0Start01Start012Start0123". But what I see is "Start0 Start01
Start012 Start0123". Where is the extra 'space' coming from?
Thank you again.
Chris
Protected Overrides Sub OnPaint(ByVal vpe As PaintEventArgs)
MyBase.OnPaint(vpe)
Dim g As Graphics = vpe.Graphics
Dim b As SolidBrush = New SolidBrush(Color.Black)
Dim YCoord As Single = 100
Dim XCoord As Single = 100
Dim f As New Font("Times New Roman", 12, _
FontStyle.Regular, GraphicsUnit.Pixel)
Dim s As String = "Start"
For i As Integer = 0 To 3
s += Integer.Parse(i).ToString
g.DrawString(s, f, b, XCoord, YCoord)
XCoord += g.MeasureString(s, f).Width
Next i
End Sub 4 1000
Christian, the on-line docs do say.
Quote: "The MeasureString method is designed for use with individual strings
and includes a small amount of extra space before and after the string to
allow for overhanging glyphs. Also, the DrawString method adjusts glyph
points to optimize display quality and might display a string narrower than
reported by MeasureString. To obtain metrics suitable for adjacent strings
in layout (for example, when implementing formatted text), use the
MeasureCharacterRanges method."
Perhaps the "extra space" you refer to is merely just the additional extra
space before and after the string to allow for the overhanging glyphs. I've
spent the past 45 mins attempting to get a demo together for you using
MeasureCharacterRanges but without success. My gut feeling is that you
should focus your efforts here and not use "MeasureString". If/when you get
it working please post a code excerpt.
Regards
Hexathioorthooxalate.
"Christian O'Connell" <cd********@hotmail.com> wrote in message
news:9a**************************@posting.google.c om... Hi, please excuse this, my third posting today. It is my last I promise.
When I past this into form1, I am expecting to see "Start0Start01Start012Start0123". But what I see is "Start0 Start01 Start012 Start0123". Where is the extra 'space' coming from? Thank you again. Chris
Protected Overrides Sub OnPaint(ByVal vpe As PaintEventArgs) MyBase.OnPaint(vpe) Dim g As Graphics = vpe.Graphics Dim b As SolidBrush = New SolidBrush(Color.Black) Dim YCoord As Single = 100 Dim XCoord As Single = 100 Dim f As New Font("Times New Roman", 12, _ FontStyle.Regular, GraphicsUnit.Pixel)
Dim s As String = "Start" For i As Integer = 0 To 3 s += Integer.Parse(i).ToString g.DrawString(s, f, b, XCoord, YCoord) XCoord += g.MeasureString(s, f).Width Next i
End Sub
Hex, thank you. I can't get it to work either.
Please please can someone help me out with a basic skeleton few lines
that prints displays strings using a graphics object without spaces. I
can't see how to do it. My code is below. Google doesn't give any
hints/hits using the 'MeasureCharacterRanges' subroutine to get a
working example.
Thank you
Christian
"test" <ru***@clara.co.uk> wrote in message news:<10****************@echo.uk.clara.net>... Christian, the on-line docs do say.
Quote: "The MeasureString method is designed for use with individual strings and includes a small amount of extra space before and after the string to allow for overhanging glyphs. Also, the DrawString method adjusts glyph points to optimize display quality and might display a string narrower than reported by MeasureString. To obtain metrics suitable for adjacent strings in layout (for example, when implementing formatted text), use the MeasureCharacterRanges method."
Perhaps the "extra space" you refer to is merely just the additional extra space before and after the string to allow for the overhanging glyphs. I've spent the past 45 mins attempting to get a demo together for you using MeasureCharacterRanges but without success. My gut feeling is that you should focus your efforts here and not use "MeasureString". If/when you get it working please post a code excerpt.
Regards Hexathioorthooxalate. "Christian O'Connell" <cd********@hotmail.com> wrote in message news:9a**************************@posting.google.c om... Hi, please excuse this, my third posting today. It is my last I promise.
When I past this into form1, I am expecting to see "Start0Start01Start012Start0123". But what I see is "Start0 Start01 Start012 Start0123". Where is the extra 'space' coming from? Thank you again. Chris
Protected Overrides Sub OnPaint(ByVal vpe As PaintEventArgs) MyBase.OnPaint(vpe) Dim g As Graphics = vpe.Graphics Dim b As SolidBrush = New SolidBrush(Color.Black) Dim YCoord As Single = 100 Dim XCoord As Single = 100 Dim f As New Font("Times New Roman", 12, _ FontStyle.Regular, GraphicsUnit.Pixel)
Dim s As String = "Start" For i As Integer = 0 To 3 s += Integer.Parse(i).ToString g.DrawString(s, f, b, XCoord, YCoord) XCoord += g.MeasureString(s, f).Width Next i
End Sub
If you really want control over your text output then go with GDI and use
TextOut. The GDI+ DrawString will only give you a headache if you try to use
it for precise text printing. I really hate it. I hope Microsoft will change
the way DrawString works with video display and not worry about device
independence, but I doubt it.
"Christian O'Connell" <cd********@hotmail.com> wrote in message
news:9a**************************@posting.google.c om... Hex, thank you. I can't get it to work either.
Please please can someone help me out with a basic skeleton few lines that prints displays strings using a graphics object without spaces. I can't see how to do it. My code is below. Google doesn't give any hints/hits using the 'MeasureCharacterRanges' subroutine to get a working example. Thank you Christian
"test" <ru***@clara.co.uk> wrote in message
news:<10****************@echo.uk.clara.net>... Christian, the on-line docs do say.
Quote: "The MeasureString method is designed for use with individual
strings and includes a small amount of extra space before and after the string
to allow for overhanging glyphs. Also, the DrawString method adjusts glyph points to optimize display quality and might display a string narrower
than reported by MeasureString. To obtain metrics suitable for adjacent
strings in layout (for example, when implementing formatted text), use the MeasureCharacterRanges method."
Perhaps the "extra space" you refer to is merely just the additional
extra space before and after the string to allow for the overhanging glyphs.
I've spent the past 45 mins attempting to get a demo together for you using MeasureCharacterRanges but without success. My gut feeling is that you should focus your efforts here and not use "MeasureString". If/when you
get it working please post a code excerpt.
Regards Hexathioorthooxalate. "Christian O'Connell" <cd********@hotmail.com> wrote in message news:9a**************************@posting.google.c om... Hi, please excuse this, my third posting today. It is my last I promise.
When I past this into form1, I am expecting to see "Start0Start01Start012Start0123". But what I see is "Start0 Start01 Start012 Start0123". Where is the extra 'space' coming from? Thank you again. Chris
Protected Overrides Sub OnPaint(ByVal vpe As PaintEventArgs) MyBase.OnPaint(vpe) Dim g As Graphics = vpe.Graphics Dim b As SolidBrush = New SolidBrush(Color.Black) Dim YCoord As Single = 100 Dim XCoord As Single = 100 Dim f As New Font("Times New Roman", 12, _ FontStyle.Regular, GraphicsUnit.Pixel)
Dim s As String = "Start" For i As Integer = 0 To 3 s += Integer.Parse(i).ToString g.DrawString(s, f, b, XCoord, YCoord) XCoord += g.MeasureString(s, f).Width Next i
End Sub
Christian,
You will get better results by using one of the MeasureString overloads
that takes a StringFormat parameter. Use an instance of
StringFormat.GenericTypographic for this and you should get better results.
The overloads that don't specify a StringFormat object use the default which
includes some space around the string.
I normally use the MeasureString(string, font, maxWidth, myStringFormat)
overload when I want more exact results. Just make sure to make maxWidth
big enough so that you don't run into the maximum.
You may want to use Google to search
microsoft.putlic.dotnet.framework.drawing for more detailed discussions on
GDI+ drawing and measuring strings.
Ron Allen
"Christian O'Connell" <cd********@hotmail.com> wrote in message
news:9a**************************@posting.google.c om... Hi, please excuse this, my third posting today. It is my last I promise.
When I past this into form1, I am expecting to see "Start0Start01Start012Start0123". But what I see is "Start0 Start01 Start012 Start0123". Where is the extra 'space' coming from? Thank you again. Chris
Protected Overrides Sub OnPaint(ByVal vpe As PaintEventArgs) MyBase.OnPaint(vpe) Dim g As Graphics = vpe.Graphics Dim b As SolidBrush = New SolidBrush(Color.Black) Dim YCoord As Single = 100 Dim XCoord As Single = 100 Dim f As New Font("Times New Roman", 12, _ FontStyle.Regular, GraphicsUnit.Pixel)
Dim s As String = "Start" For i As Integer = 0 To 3 s += Integer.Parse(i).ToString g.DrawString(s, f, b, XCoord, YCoord) XCoord += g.MeasureString(s, f).Width Next i
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: fig000 |
last post by:
Hi,
I'm relatively new to Javascript so please bear with me on what
might sound like silly questions.
This is what I want to do:
I'm working in classic asp (I have to for this project). I...
|
by: nospam |
last post by:
THIS IS the DOTNETJUNKIES MESSAGE
-------------------------
We're Sorry
As many of you know we have recently launched SqlJunkies.com. We have
overhauled our runtime and will be using it on...
|
by: anon |
last post by:
Post Forwarding question......
For this control below,
<asp:Button runat="server" PostTargetUrl="page2.aspx" />
The Attribute: PostTargetUrl="page2.aspx"
Is this PostTargetUrl Attribute...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. ...
|
by: Paul Cochrane |
last post by:
Hi all,
I've got an application that I'm writing that autogenerates python code
which I then execute with exec(). I know that this is not the best way to
run things, and I'm not 100% sure as to...
|
by: Sebastian Hiller |
last post by:
Hello,
i'm new to .Net (i'm using VB as language and i'm working in the
code-behind mode) and i can't solve the following problem:
I have a WebForm and want to Add a UserControl...
|
by: Brad |
last post by:
I have another hopefully simple question. I am so used to writing VB .Net
windows apps that there are some things in ASP .Net that just does not easily
cross over. I know how to pass variables to...
|
by: Eric_Dexter |
last post by:
def simplecsdtoorc(filename):
file = open(filename,"r")
alllines = file.read_until("</CsInstruments>")
pattern1 = re.compile("</")
orcfilename = filename + "orc"
for line in alllines:
if not...
|
by: SM |
last post by:
Hello,
I have a simple question, but can't find the answer.
I have a string that contains a path to a file
I want to add another string to the end of that string
So, if i have :
path =...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |