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.
Syncfusion Feedback

text alignment in table (GDI)

Thread ID:




43122 Apr 15,2006 08:05 PM UTC WinForms 0
Tags: FAQ
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.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon