From: Tony Johansson on 11 Apr 2010 09:38 Hi! If I set sf.Alignment = StringAlignment.Near; it will draw at the far left which is correct But when I set the sf.Alignment = StringAlignment.Far; in the code below no text is displayed. so I wonder if I don't specify a rectangle what is the area that .NET will use to draw ? Graphics g = this.CreateGraphics(); FontFamily fm = new FontFamily("Arial"); Font f = new Font(fm, 10); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; g.DrawString("GDI+ in Microsoft .NET", f, Brushes.Red, 0, 0, sf); //Tony
From: Peter Duniho on 11 Apr 2010 13:16 Tony Johansson wrote: > Hi! > > If I set sf.Alignment = StringAlignment.Near; it will draw at the far left > which is correct > But when I set the sf.Alignment = StringAlignment.Far; in the code below no > text is displayed. > so I wonder if I don't specify a rectangle what is the area that .NET will > use to draw ? The rectangle that contains the text you asked it to draw. "Near" and "Far" are just "text-direction-agnostic" descriptions of alignment. But if you know the text direction being used, you can tell what alignment corresponds to each. For left-to-right text, "Far" is just "right-aligned". So when you tell Graphics to draw your text right-aligned at point (0, 0), it draws the text so that the right edge of the text winds up at that point. You'll see the text being drawn if you specify a location to draw it that is not at the very left edge of the visible area of the Graphics instance. Pete
|
Pages: 1 Prev: windows forms controls Next: is there a bug in RectangleConverter |