DataGridView DrawString

Hello. I am displaying two different kinds of information in a datagridview. I have a class that extends the DataGridViewTextBoxCell and handles the merging of several cells for one row type and while it works, the quality of the text displayed is not good (see attached file).  If I click on the cell, it will redraw the text to a nice clear quality. I've included the relevant code of the override of the Paint event. I have tried a couple different combinations of SmoothingModes and such (I've left them commented in the code), but no luck. Any help is greatly appreciated!


        Dim sf As New StringFormat()
        sf.Alignment = StringAlignment.Near
        sf.LineAlignment = StringAlignment.Center
        sf.Trimming = StringTrimming.EllipsisCharacter

       strText = Me.OwningRow.Cells(_LeftColumn).Value.ToString()      

        'graphics.SmoothingMode = SmoothingMode.AntiAlias
        'graphics.CompositingQuality = CompositingQuality.HighQuality
        'graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias

        'graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        'graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
        'graphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality

        graphics.DrawString(strText, cellStyle.Font, Brushes.Black, rectDest, sf)
grid.PNG
nbrunsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ess KayEntrapenuerCommented:
why not have it pop up when a cell is clicked, like a tooltip, or toolalert
0
nbrunsAuthor Commented:
I need to display the part number in the grid regardless of which type it is, so having it be in a tooltip wouldn't work. I have attached a screen shot of the grid.
grid2.PNG
0
Ess KayEntrapenuerCommented:
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

nbrunsAuthor Commented:
Thanks for your suggestion, but the code I am using is pretty much the same. I have tried different font sizes and smoothing modes, but I still end up with the text not displaying clearly.
0
nbrunsAuthor Commented:
I ended up figuring out the issue. Because I was merging several cells and overriding the paint event, the graphics.DrawString was excecuting multiple times. I changed it to only write the text once and it fixed the problem. Hopefully this will help someone else.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nbrunsAuthor Commented:
I figured out what the issue was without any assistance from other posters.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.