We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.

# text alignment in table (GDI)

#### Replies:

43122 Apr 15,2006 08:05 PM UTC WinForms 0
 Subscribe to this post Tags: FAQ
Marius
Asked On April 15, 2006 08:05 PM UTC

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.