code_junkie

How to draw subsection of text using .net graphics

Nov 13th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. //get the actual bounds of this entire item spanning across multiple cells
  2. RectangleF sRectF = GetItemRectF(startX + leftMargin + 2, widthForItem, cellBounds, calItem);
  3.  
  4. //we clear it out first, otherwise the text looks bolded if we keep drawing a black string over and over
  5. //todo should figure out how to only draw this cells section? cellBounds subsection of sRectF somehow
  6. graphics.DrawString(calItem.Description, new Font("Tahoma", 8), new SolidBrush(itemBackColor), sRectf);
  7. graphics.DrawString(calItem.Description, new Font("Tahoma", 8), new SolidBrush(Color.Black), sRectF);
  8.  
  9. Region tempRegion = graphics.Clip;
  10. graphics.Clip = new Region(cellBounds);
  11. graphics.DrawString(calItem.Description, new Font("Tahoma", 8), new SolidBrush(Color.Black), sRectF);
  12. graphics.Clip = tempRegion;
Add Comment
Please, Sign In to add comment