Dear All,
I am getting Out of Memory exception sometimes while executing this code...
wot am I doing wrong here....
private int GetStringLength(string StringToMeasure)
{
System.Drawing.Graphics oGraphics = this.CreateGraphics();
Font sGridFont = _MyGrid.Font;
string sDummyString = StringToMeasure;
SizeF stringSize = new SizeF();
stringSize = oGraphics.MeasureString(sDummyString, sGridFont);
return ((int)stringSize.Width + 10);
}
Please help...
TALIA
Many Regards
Jack
cody - 27 Jul 2004 09:55 GMT
I can only imagine that something is wrong with the font or you pass an
extremely long string to that method.
If both doesn't apply I guess it is a bug.
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
> Dear All,
> I am getting Out of Memory exception sometimes while executing this code...
[quoted text clipped - 15 lines]
> Many Regards
> Jack
Herfried K. Wagner [MVP] - 27 Jul 2004 11:59 GMT
* sunil@volcanomail.com (Jack Wright) scripsit:
> I am getting Out of Memory exception sometimes while executing this code...
> wot am I doing wrong here....
[quoted text clipped - 5 lines]
> SizeF stringSize = new SizeF();
> stringSize = oGraphics.MeasureString(sDummyString, sGridFont);
\\\
oGraphics.Dispose()
///
> return ((int)stringSize.Width + 10);

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/