Questions tagged [drawstring]

Graphics.DrawString is a method in the .Net Framework's System.Drawing namespace, by which code can draw text onto an image in .Net code. This is mainly used in ASP.Net, as TextRenderer.DrawText (from System.Windows.Forms) provides more reliable functionality in Windows Forms applications.

313 questions
0
votes
0 answers

vb.net DrawString X-Position

I have problems with positioning within the DrawString method. However, only on the X axis. No matter what value I recommend for the distance from above - it fits. Therefore, I assume that I have made everything right. For example, An X in Arial…
0
votes
0 answers

Get the last character pixel position drawn with DrawString in C#?

So I'm writing a text on an image with DrawString in a rectangle. My text is written on multiple line in my rectangle. How can I get the pixel position of the last character drawn on my image ? Because this character can be at any Width because of…
tucotraff
  • 61
  • 4
0
votes
0 answers

Split String when exceed length on Roll Paper

In my c# windows form application for printing I'm using roll paper. And its working well. My format is like Qty Item Price 1 ItemName $2.00 And I am using, g.DrawString(item.quantity.PadRight(2) + item.menu_title.PadRight(24) +…
Onick Ahmed
  • 91
  • 1
  • 15
0
votes
1 answer

Java split a string into multiple ones at a selected position

I'm trying to make a method which will split a long text into lines and draw them on documents using Graphics. I managed to figure out how to split the lines that I get from a JTextArea component but don't know how to make them wrap/break when a…
Ssiro
  • 127
  • 1
  • 5
  • 18
0
votes
1 answer

Drawing Strings over PaintedImage Java

I need to draw strings on a painted image. The project I am working on also requires the string to move around the screen at least 22 times in a second. Hence, its position can be anywhere on the image. So, redrawing the image with the string on it…
paddy
  • 123
  • 1
  • 2
  • 13
0
votes
2 answers

How to align dot in currency while printing

I have something like this: Public Function ItemsToBePrinted() Dim p_dt As DataTable = Model_Query(2) Dim p_str As String = "" Dim StringToPrint As String = "" For Each drow As DataRow In p_dt.Rows Dim str_itemName As…
vbnewbie
  • 206
  • 6
  • 26
0
votes
4 answers

Graphics.DrawString to multiple rectangles

I am trying to write a function that needs to draw a string to an image. The image has anywhere from 1-5 textboxes, which each have a x,y, width, and height. These details are defined in an XML file which I am parsing, so I have access to these for…
JakeD
  • 407
  • 2
  • 7
  • 19
0
votes
1 answer

.net DrawString Hebrew font with zero-width characters

Are there any additional properties or parms in the DrawString to solve this problem. I have a Hebrew font with many zero-width characters so that two characters should render in the same location. This example shows the .NET problem on the left,…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
0
votes
1 answer

Issue Using Graphics DrawString On Resize

Goal I want to display a vertical text on the left of a user control to let a user know which product they are creating/editting. Like so: How am I building it? This user control is made up of three controls. Label with text "Product…
Alex
  • 4,821
  • 16
  • 65
  • 106
0
votes
1 answer

DrawString graphics dissappearing

I am trying to draw a string over a progress bar as outlined here and here. The progress bar is located on one of a series of tab pages in my tab control. This is my code: int percent = 55; using (Graphics gr =…
mathgenius
  • 503
  • 1
  • 6
  • 21
0
votes
4 answers

How can I clear the Graphics before drawing another letter?

private void timer1_Tick(object sender, EventArgs e) { counter--; DrawLetter(); if (counter == 0) { t.Stop(); TakeScreenShot(); } } private void DrawLetter() { …
software is fun
  • 7,286
  • 18
  • 71
  • 129
0
votes
2 answers

Superimposed chars in drawstring in C#

I'm working on a game, it's like a snake, but you type something when the game starts and the word that you type becomes the body of the snake. So... I have almost everything figured out, but when drawing the snake, the letters overlap, and I want…
OPMUANRK
  • 13
  • 5
0
votes
1 answer

How do I make DrawString() take the current viewport into account when drawing, like Draw() does?

Currently, all my textures are being scaled and move into the right position when the viewport that I draw them in changes size or position (I don't have to do any calculations myself to do this). However, when I use DrawString() (while still in the…
Erra
  • 93
  • 6
0
votes
1 answer

Graphics.DrawString: count the number of characters fully displayed in rectangle efficiently

I'm using custom drawing to draw a string in a WinForms application. The classic Graphics.DrawString method is used for that: g.DrawString(text, font, brush, rect, stringFormat); The output string text can be clipped by the rectangle rect, and I…
TecMan
  • 2,743
  • 2
  • 30
  • 64
0
votes
0 answers

GDI+ Graphics.DrawString with TextTrimming set to EllipsisCharacter doesn't work if output rectangle contains one character

We use the classic GDI+ DrawString method to output text and set the Trimming property of its format parameter to EllipsisCharacter (see also the StringTrimming enumeration). If the output rectangle is enough small so it can display just one…
TecMan
  • 2,743
  • 2
  • 30
  • 64