views:

694

answers:

1

I'm trying to implement a .NET control that functions like the Firefox Awesome Bar. To that end, I'm trying to bold and underline searched for characters inside of search results displayed in a ListView. I've set up OwnerDraw and I'm using Graphics.MeasureCharacterRanges to figure out how big the characters are. The problem I'm having is that the values passed back from that method aren't always perfect. I end up with a few extra pixels here and there or two characters that are too close to each other. Is there an easy fix? Another way to draw different parts of the same word with different font settings?

A: 

I figured this out. I had to switch to using TextRenderer.DrawText and TextRenderer.MeasureText. I made sure to pass TextFormatFlags.NoPadding to both of those methods.

ryansch