hi i am using a simple code to draw a table with GDI in c# the table position is set automaticaly and i also want to draw a table name automatically centered,maybe someone know some proportions of pixels and strings lengths. i can only know the center of the table, but how to draw a table name (can be different lengths) in the center, here us my example:
Graphics g = gg.Graphics;
Pen p = new Pen(Color.Black);
int last = 0; //just row koeficient
int last2 = 0; //just row koeficient
int last3 = 0; //just row koeficient
for (int i = 0; i < 18; i++)
{
if ((i) == 13)
{
last = (_kof * (i));
}
if ((i) == 14)
{
g.DrawLine(p, _linePozicion.X + _width, _linePozicion.Y + (_kof * i), _linePozicion.X + (_width * 2), _linePozicion.Y + (_kof * i));
}
if ((i) == 16)
{
g.DrawLine(p, _linePozicion.X + _width, _linePozicion.Y + (_kof * i), _linePozicion.X + (_width * 2), _linePozicion.Y + (_kof * i));
}
}
g.DrawString(title, _titleFont, Brushes.Black, (_linePozicion.X + _width + _linePozicion.X + (_width* 2)) / 2 - (title.Length * 3), (_linePozicion.Y+last +2), new StringFormat());
i set title here manualy , but i what to center title automatic, any ideas, thanks.