Tom Heavey
11/29/2004 11:49:00 PM
I have found a solution. If I set the FormatFlags to NoClip the code works.
This brings up a couple of questions. Why does this work and is there a more
complete explanation of the FormatFlags especially the top bit (32K bit) that
is not documented? I am also wondering about the property nativeFormat that
is not documented, but is displayed in the debugger. Some internet help
features say this is a private property. How do private properties get
exposed in the debugging environment?
Thank you,
Tom
"THeavey" wrote:
> In the following code the text will not display if I use the
> stringFormat in the Drawstring and will separate the two strings if I
> do not use the stringFormat:
>
> graph = e.Graphics;
> pen = new Pen(Color.Black,2);
>
> //graph.DrawLine( pen,100,100,200,100);
> drawFont = new System.Drawing.Font("Arial", 8, FontStyle.Bold);
> drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
>
> String sTest = "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";
> Region[] stringRegions = new Region[1];
> StringFormat stringFormat = new StringFormat();
> stringFormat = StringFormat.GenericDefault;
> stringFormat.Trimming = System.Drawing.StringTrimming.Character;
> stringFormat.FormatFlags += 16384;
> //graph.TextRenderingHint = TextRenderingHint.AntiAlias;
> CharacterRange[] characterRanges = new CharacterRange[1];
> characterRanges[0] = new CharacterRange(0,sTest.Length);
> stringFormat.SetMeasurableCharacterRanges(characterRanges);
> stringRegions = graph.MeasureCharacterRanges( sTest, drawFont,
> this.ClientRectangle, stringFormat);
> RectangleF rect = stringRegions[0].GetBounds(graph);
> //rect.Offset(10,10);
> //graph.DrawString(sTest,drawFont,drawBrush,rect);
> graph.DrawString(sTest,drawFont,drawBrush,rect,stringFormat);
> rect.Offset(rect.Width,0);
> //graph.DrawString(sTest,drawFont,drawBrush,rect);
> graph.DrawString(sTest,drawFont,drawBrush,rect,stringFormat);
>
> Please help
>