473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problems with printing right aligned text.

Hello!

I am using a thirdparty gridcontrol which has a bug in it. It consists of
that when setting a column to be right aligned it doesn't work as it should.
The column gets rightaligned, but only for text that has the same length.
The longer the text in each cell is, the longer to the left the text is
being printed. (Take a look at this file to see what it looks like:
http://www.lowrad.net/files/grid_bug.jpg)

I contacted the support about this, but they said the solution was to
override the PaintForeground method for the cell class. I did that, and
experienced the exact same bug as with the original PaintForeground method.
Unfortunately I don't have the sourcecode for the gridcontrol, but this is
my code:

protected override void PaintForeground(Xceed.Grid.GridPaintEventArgs e)
{
if (this.HorizontalAlignment == Xceed.Grid.HorizontalAlignment.Right)
{
string text = System.Convert.ToString(this.Value);
System.Drawing.SolidBrush brush = new
System.Drawing.SolidBrush(this.ForeColor);
System.Drawing.StringFormat format = new
System.Drawing.StringFormat();
format.Alignment = System.Drawing.StringAlignment.Far;

e.Graphics.DrawString(text,this.Font,brush,e.Clien tRectangle,format);
}
else
{
base.PaintForeground(e);
}
}

Now, it suprised me that the exact same problem happened since I thought
printing the text with DrawString should do it. My question now is how the
DrawString method determines where to print the text? In my eyes it must be
using the e.ClientRectangle object and the format object combined...
Therefore I started looking at the clientrectangle's size and location each
time the PaintForeground method was called, to see if they changed. But they
don't and that's where I'm stuck. How come the alignment doesn't work? What
else than the size and location of the rectangle is used when printing text
aligned to the right?

I'm VERY thankful for help here.

/David.
Nov 15 '05 #1
0 1582

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andres Mas Torrecillas | last post by:
Hi! I'm having a little trouble with an IFRAME added in an HTML page. IFRAME has a fixed size and it contains another HTML page, which only has some text paragraphs and a pair of images aligned...
3
by: eternalD3 | last post by:
Hi, I have a problem to get this working on Opera 7.x+. This does not need to work on older Opera browsers There are problems on rendering the sub-level navigation. It aligns right on Firefox...
0
by: Jonathan | last post by:
I am trying to learn how to print with VB.net but the book I'm using has lots of mistakes. Here is the code which is almost directly copied from the book I'm using: Imports System.Drawing...
8
by: Harry Haller | last post by:
The right arrow in IE is displayed aligned to the bottom of the line. Is there any way I can display it aligned vertially in the middle? Example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
19
by: JB | last post by:
Hi All, Why doesn't this work in Firefox but is perfect in IE6? In IE6, the text is on the same line but in Firefox, the left aligned text is on the line above the right aligned text. ...
3
by: Sjef Janssen | last post by:
Is it possible to have a box (div) which sets a background-color and which contains (on the same line) text which is left aligned and text which is right aligned. (as in a table: two td's left one...
8
by: joemacbusiness | last post by:
Hi All, How do I format printed data in python? I could not find this in the Python Reference Manual: http://docs.python.org/ref/print.html Nor could I find it in Matloff's great tutorial:...
6
by: Liam Gibbs | last post by:
Hello everyone, I'm trying to program a church web site and I'm having a number of problems with the layout. The html is at http://www.altmarvel.net/Liam/index.html and the css is at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.