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.
Questions tagged [drawstring]
313 questions
1
vote
3 answers
Flip text vertically using Drawstring
I have some code that writes some text to a defined region.
graphics.DrawString(text, goodFont, Brushes.Black, textarea, stringFormat);
There are some cases where I would like to flip the text on the horizontal so that it goes from:
To
I have…

markdozer
- 121
- 3
- 8
1
vote
2 answers
How to call GDipDrawString method in c#
I want to call native gdi+ method to improve performance of text drawing. Can anyone provide example?
I found the following code from reference source. I want to use this method in C# to improve the performance. How can i achieve…
user4542724
1
vote
1 answer
drawstring rotate long text 180
I use drawstring method to draw text inside rectangle ,.. i wanted to rotate the text 180 degree so i used this code
Rectangle displayRectangleh =
new Rectangle(new Point((int)posh.X, (int)posh.Y), new Size(rectwdh, recth));
…

user1477332
- 325
- 2
- 4
- 20
1
vote
4 answers
.Net DrawString font reference changes after invoking
Given the following code. Is there any potential for the first DrawString method to draw in Arial rather than Times New Roman?
protected override void OnPaint(PaintEventArgs pe)
{
Font f = new Font("Times New Roman", this.TextSize);
…

Matt Fellows
- 6,512
- 4
- 35
- 57
1
vote
0 answers
C# - DrawString draws text flipped
I'm using a theme with a custom TabControl control.
The control draws text for each tab using the DrawString method like so:
using (SolidBrush B = new SolidBrush(FC))
{
G.DrawString(TabPages[i].Text, Theme.GlobalFont(FontStyle.Regular, 10), B,…

Gilbert Williams
- 970
- 2
- 10
- 24
1
vote
1 answer
Java how do I make drawstring print something without it being replaced in the next iterations of paintComponent
So I have a code that has a text field and when press a button and enter some text, that text will appear where ever it is clicked on the panel. How do I make it so that every time I click somewhere on the panel, the old string on the panel doesn't…

Eric Z
- 21
- 1
1
vote
1 answer
C# Tabs Rotate Text
I am having some issues rotating the text on a tab. The tabs originally worked just fine, but then I wanted to bold the text when selected, so I used the Draw Item Event. I added a RotateTransform and a TranslateTransform, but its not working. …

akb
- 43
- 7
1
vote
1 answer
Best way to attach a string variable onto a moving texture, and have it drawn?
Currently working on a game (similar to a space defender game with random enemy spawns) and need the enemies to have a random.next attached to label the enemy.
However I'm having trouble figuring a way to do so, since the enemy is also moving on its…

kevin man
- 297
- 3
- 10
1
vote
1 answer
Creating autosized image (png) from multi-line string in C#
I am seeking to create an image from user input text. ultimately, it would be used to send to twitter along with a status update.
I cannot control the length of the user text - it will be variable.
Originally, I was able to draw a png from the text…

Dave
- 167
- 17
1
vote
1 answer
Why does Drawstring make font wider in Listbox?
I have a Listbox in vb.net. I was able to draw my items (with the DrawItem event) with different colors depending on conditions. It works.
The problem is that the size of the string drawned is wider that the original string as you can see in the…

Yoann ARNAUD
- 23
- 6
1
vote
1 answer
How to delete/remove/undo DrawString in C# WinForm
My form has a background image. I have some pictureBoxes i am using as buttons. I am attempting to have a MouseEnter/MouseLeave event to display label or pictureBox.
I have been trying various approaches. I am getting similar results- The label…

HoustoneD
- 63
- 1
- 3
- 15
1
vote
1 answer
How to draw string in GDI+ Graphics.DrawString that honors the underline chars when I use ampersand?
I'm using GDI+ to draw a string but it does not act like windows DrawText when it comes to honoring the & in front of the a char. It just draws & and not underlines next char. Maybe there is an option to turn it on/off? Please help.

serge
- 1,590
- 2
- 26
- 49
1
vote
1 answer
drawString method doesn't work
I have a JPanel object of which I'm using it as a canvas to draw rectangular shapes and call updateString(String c, int x, int) method to draw a String c whenever I call that method in my main.
I also have local variable called private Graphics…

Burak.
- 598
- 7
- 19
1
vote
1 answer
Using drawstring in scaled graphics2d results in various spacing and glyph
I am trying to zoom out a text using the code below, but scaling does not scale the font of the text properly. I believe it does not keep the result the same.
My goal is to zoom html strings, but the issue still remains there, too. For example, if I…

Soley
- 1,716
- 1
- 19
- 33
1
vote
1 answer
Different text size on the same images
I have 2 same images.
When I try to add rectangle and text (using graphics) to this images, the rectangle is the same BUT the text on image is different size..
the code is:
g.DrawRectangle(new Pen(Color.Blue, 5), new Rectangle(10, 10, 200,…

Sergey Buyanov
- 13
- 2