473,698 Members | 2,153 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 2852
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
1047
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 New Roman", 8 ),
5
27155
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, TheHeight1 + (390 + yPos))
5
1224
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
8155
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
3026
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 past able to do this within Visual Basic using its printer object. Visual Basic's printer object uses...
7
2579
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
12650
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 happens? What kind of StringFormat is used when this parameter is missing?
6
2679
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 displayed inside an owner
2
3335
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 = this.getBufferStrategy(); Graphics2D g = null; if(scrollPos>lastCoveredPos) lastCoveredPos =...
10
3640
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 fine, but for some reason I need to click the button twice to be able to see something on picturebox....
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9026
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3045
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
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.