473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with graphics.DrawSt ring

I've got a control that you can resize the contents of one of the text
fields inside it. When the contents are resized to smaller than the
text, I remove some of the end of the text and substitute ... at the
end.

This is where the wierdness sets in. Any time I remove or change some
letters at the END of the text and draw, the spacing throughout the
text string changes!!! So when I resize it in and out, the whole line
looks like its expanding and contracting.

I am using Graphics.DrawSt ring with mostly default values. My font is
Sans Serif 8.25. I've checked the microsoft .net listview and it
doesn't show this behavior with this same font so I'm trying to figure
out what they are doing that I am not!

Why is my text line expanding and contracting as it's changed near the
end?
Oct 8 '06 #1
3 2831
I'm not exactly sure why, but I think the way around this is to use GDI's
DrawText. In our own custom controls, we ran into various problems with
Graphcis.DrawSt ring and switched everything to DrawText. It's a bit of a
paint to have to deal with GDI, but it's definitely more reliable.


"Allen" <no**@none.comw rote in message
news:6r******** *************** *********@4ax.c om...
I've got a control that you can resize the contents of one of the text
fields inside it. When the contents are resized to smaller than the
text, I remove some of the end of the text and substitute ... at the
end.

This is where the wierdness sets in. Any time I remove or change some
letters at the END of the text and draw, the spacing throughout the
text string changes!!! So when I resize it in and out, the whole line
looks like its expanding and contracting.

I am using Graphics.DrawSt ring with mostly default values. My font is
Sans Serif 8.25. I've checked the microsoft .net listview and it
doesn't show this behavior with this same font so I'm trying to figure
out what they are doing that I am not!

Why is my text line expanding and contracting as it's changed near the
end?

Oct 8 '06 #2
"Allen" <no**@none.comw rote in message
news:6r******** *************** *********@4ax.c om...
I've got a control that you can resize the contents of one of the text
fields inside it. When the contents are resized to smaller than the
text, I remove some of the end of the text and substitute ... at the
end.

This is where the wierdness sets in. Any time I remove or change some
letters at the END of the text and draw, the spacing throughout the
text string changes!!! So when I resize it in and out, the whole line
looks like its expanding and contracting.

I am using Graphics.DrawSt ring with mostly default values. My font is
Sans Serif 8.25. I've checked the microsoft .net listview and it
doesn't show this behavior with this same font so I'm trying to figure
out what they are doing that I am not!

Why is my text line expanding and contracting as it's changed near the
end?
I think this is caused when you specify too small a rectangle for it to draw
into. If you just make the rectangle a bit longer it should work fine.
Oct 9 '06 #3

for anyone who has this problem in the future I figured out what the
problem was. It's a very obscure property in the graphics object
called TextRenderingHi nt. Setting this like so

e.Graphics.Text RenderingHint =
System.Drawing. Text.TextRender ingHint.AntiAli as;
at the beginning of my OnPaint method of my control fixes the problem
%100.
On Sun, 08 Oct 2006 14:45:55 -0600, Allen <no**@none.comw rote:
>I've got a control that you can resize the contents of one of the text
fields inside it. When the contents are resized to smaller than the
text, I remove some of the end of the text and substitute ... at the
end.

This is where the wierdness sets in. Any time I remove or change some
letters at the END of the text and draw, the spacing throughout the
text string changes!!! So when I resize it in and out, the whole line
looks like its expanding and contracting.

I am using Graphics.DrawSt ring with mostly default values. My font is
Sans Serif 8.25. I've checked the microsoft .net listview and it
doesn't show this behavior with this same font so I'm trying to figure
out what they are doing that I am not!

Why is my text line expanding and contracting as it's changed near the
end?
Oct 27 '06 #4

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

Similar topics

0
1043
by: nest | last post by:
Im compiling on xp box but need to deploy on 98SE box. Application works great except printing, after i try to print on 98SE box it freezes completly. Code is quite standard: private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) while ( trenutniVirman < iBrojac ) { e.Graphics.DrawString(arrayMatrica, new Font("Times...
5
27140
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2,...
5
1220
by: brix_zx2 | last post by:
vb.net 2k3: I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it. Dim g As Graphics Dim LabelText As String LabelText = "--" x = x + 20
1
8142
by: Lars Netzel | last post by:
Hi! In VB.NET want to draw my own items in a ComboBox I have added a ComboBox to the Form with this. ----------------------------------------------------------------------------------- 'ComboBox1 '
7
3012
by: Michael Galvin | last post by:
I am trying to use Python to send to the printer a calender filled with a mix of text and simple graphics. I want to draw on the printed page something like a table with 6 rows and 7 columns to represent a calendar. I want to place text precisely within those boxes on the printed page. I am using Python 2.4 on Windows XP I was in the...
7
2566
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be stupid or missing the point. I used DrawString( ) as a simple test but I cannot get it to work at all unless I handle my custom controls Paint event.
2
12636
by: Tony Johansson | last post by:
Hello! If I use the DrawString below with object of StringFormat as the last object it works good. If I instead remove object StringFormat below as the last object of DrawString I get some rows that are not printed correctly. It's look like when toner is too low for the printer.This is only for some rows. Can somebody explain why this...
6
2667
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 string into multiple lines. Is there a way to find out into how many lines the string was split? I am asking because this string is being...
2
3325
by: drsmooth | last post by:
Hi, i have made several different things using a double buffer and a jframe before but never had this problem: if you look thrugh the code, you can see that i draw a whole bunch of stuff to the screen and sometimes, i get a frame or two of just blank jframe color public void draw() { BufferStrategy bf =...
10
3633
by: anuking | last post by:
Hi, I made a tool that compares the texts from 2 richtextboxes and then marks the characters that are different in red. An option needs me to overlap these 2 text data to show the exact difference. I used a picturebox which is contained in a panel and draw the characters in respective colors using Graphics class. Everything is working...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
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 we have to send another system
1
1198
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.