473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Antialiasing the text in Windows Forms Controls

RSH
I have been experimenting with overriding the Paint event on Win Form
controls...more specifically trying to force the text to render as
Antialiased text. I have not been successful in any of the methods Ive
tried...is there a trick? Any information or examples would be greatly
appreciated.

Thanks!
Ron
Jan 21 '08 #1
2 6980
Ron,

What is the call to DrawString that you are making? Are you setting the
TextRenderingHint property on the Graphics instance you are using to draw to
the form?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"RSH" <wa*************@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have been experimenting with overriding the Paint event on Win Form
controls...more specifically trying to force the text to render as
Antialiased text. I have not been successful in any of the methods Ive
tried...is there a trick? Any information or examples would be greatly
appreciated.

Thanks!
Ron
Jan 21 '08 #2
RSH
Nicholas,

Here is what I have pieced together so far. My problem is that I see both
the text that was set in the label1.Text property, as well as my formatted
text. I cant figure out how to get rid of the previous text as setting the
label1.Text property = ""; erases all text.

private void SmoothingFonts_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)

{

Label lbl = (Label)sender;

Font TextFont = new Font("Arial", 12, FontStyle.Regular);

e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

int height = lbl.Size.Height + 20;

int width = lbl.Size.Width + 500;

Size size = new Size(width, height);

Rectangle rect = new Rectangle(lbl.Location, size);

e.Graphics.DrawString(lbl.Text, TextFont, Brushes.White,
lbl.ClientRectangle);

}

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:9B**********************************@microsof t.com...
Ron,

What is the call to DrawString that you are making? Are you setting
the TextRenderingHint property on the Graphics instance you are using to
draw to the form?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"RSH" <wa*************@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>I have been experimenting with overriding the Paint event on Win Form
controls...more specifically trying to force the text to render as
Antialiased text. I have not been successful in any of the methods Ive
tried...is there a trick? Any information or examples would be greatly
appreciated.

Thanks!
Ron

Jan 21 '08 #3

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

Similar topics

5
by: Park | last post by:
In the multiple line textbox, is it possible that every sentences shows different color ? For example, test sentence 1 : red test sentence 2 : blue ....
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
6
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties...
11
by: F. Michael Miller | last post by:
I'd like to copy the listing of a directory (& sub directories) to a text file in vb.net. I'm looking for teh equivilant of the DOS command dir /s > TargetFile.txt. Thanks!
7
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source...
3
by: Guid | last post by:
Bonjour, je cherche un moyen d'appliquer un anti aliasing sur l'ensemble de mon application. Actuellement je suis a meme de le faire sur chaque controle en redefinissant la methode paint. Cela...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
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...
0
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,...
0
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...

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.