// 96 bpi bitmap (Same dpi as screen) used to get a System.Drawing.Graphics
instance for measuring.
private Bitmap GraphicsHelper;
protected void GetGraphicsHelper()
{
GraphicsHelper =
(Bitmap)global:
siGlobal.FormControls.Properties.Resources.GraphicsHelper;
}
public void LoadTables()
{
int cellHeight = 0; // Row Height variable
int i;
SizeF textSize = new SizeF();
SizeF cellSize = new SizeF();
string cellValue;
// System.Drawing.StringFormat deals with String Formatting rules when drawn
StringFormat format = new StringFormat();
format.FormatFlags = StringFormatFlags.LineLimit;
format.Trimming = StringTrimming.EllipsisWord;
using (Graphics graphics = Graphics.FromImage(GraphicsHelper))
{
// Uses the column width of a column, and a Maximum column height
cellSize = new SizeF(TableManager.Columns
.Width, (float)maxRowHeight);
// the text to be displayed
cellValue = Convert.ToString(row);
// returns a SizeF only large enough to hold the text, constrained by
width
textSize = graphics.MeasureString(cellValue, this.Font.GetFont(),
cellSize, format);
}
}