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.
Unfortunately, activation email could not send to your email. Please try again.

text alignment in table (GDI)

Thread ID:

Created:

Platform:

Replies:

43122 Apr 15,2006 04:05 PM Windows Forms 0
loading
Tags: FAQ
Marius
Asked On April 15, 2006 04:05 PM

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.

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.

;