VS 2003, .NET 1.1
I'm throughly puzzled here. I can't seem to get the method below to work...
private void AutoSizeHeight( )
{
Graphics g = this.CreateGrap hics();
int x, lineCount;
SizeF layoutSize = new SizeF(this.Widt h, this.Height * 100); // oversized
height
this.Height = (int)Math.Ceili ng(g.MeasureStr ing(base.Text, this.Font,
layoutSize, new StringFormat(), out x, out lineCount).Heig ht);
g.Dispose();
// this.Height = 400; // this works
// this.Height *= 9; // this works
this.Height *= lineCount; // this doesn't work
}
//---------[end]---------------------
This method is part of an inherited TextBox control. It's purpose is to
resize the height of the control according to the height of the contents. It
works fine if I assign a constant value to height or multiply by a constant.
But when I try to multiply by lineCount it doesn't change. Height and
lineCount definately both have values but for some reason they won't
multiply.
I'm I doing something wrong or is there something strange going on?
Note: I don't know what it means, but the lineCount is red in the Watch
window...
I'm throughly puzzled here. I can't seem to get the method below to work...
private void AutoSizeHeight( )
{
Graphics g = this.CreateGrap hics();
int x, lineCount;
SizeF layoutSize = new SizeF(this.Widt h, this.Height * 100); // oversized
height
this.Height = (int)Math.Ceili ng(g.MeasureStr ing(base.Text, this.Font,
layoutSize, new StringFormat(), out x, out lineCount).Heig ht);
g.Dispose();
// this.Height = 400; // this works
// this.Height *= 9; // this works
this.Height *= lineCount; // this doesn't work
}
//---------[end]---------------------
This method is part of an inherited TextBox control. It's purpose is to
resize the height of the control according to the height of the contents. It
works fine if I assign a constant value to height or multiply by a constant.
But when I try to multiply by lineCount it doesn't change. Height and
lineCount definately both have values but for some reason they won't
multiply.
I'm I doing something wrong or is there something strange going on?
Note: I don't know what it means, but the lineCount is red in the Watch
window...
Comment