bharat_mane
asked on
Problem with Graphics.DrawString() method...
Hi Experts,
I am facing a problem with Graphics.DrawString() method.
My Requirment is to write numbers which are right aligned..
e.g.
Items Price
Item1 34.00
Item2 551.00
Item3 5678.00
Item4 5.00
Item5 3000.00
Item6 4567.00
But I am not able to print it this way, I tried with most of the combination of StringFormat class
e.g.
StringFormat objSF = new StringFormat(StringFormatF lags.Direc tionRightT oLeft);
objSF.Alignment = StringAlignment.Far;
Can somebody tell me how to takle this problem.
Thanks
Bharat
I am facing a problem with Graphics.DrawString() method.
My Requirment is to write numbers which are right aligned..
e.g.
Items Price
Item1 34.00
Item2 551.00
Item3 5678.00
Item4 5.00
Item5 3000.00
Item6 4567.00
But I am not able to print it this way, I tried with most of the combination of StringFormat class
e.g.
StringFormat objSF = new StringFormat(StringFormatF
objSF.Alignment = StringAlignment.Far;
Can somebody tell me how to takle this problem.
Thanks
Bharat
Sorry, a typo:
StringFormat objSF = new StringFormat();
objSF.Alignment = StringAlignment.Far;
StringFormat objSF = new StringFormat();
objSF.Alignment = StringAlignment.Far;
ASKER
Thanks TheAvenger,
but i have already tried this.
It is not coming the way i am looking for,.
o/p comes like this
2
5
555.00
5555.00
5555.00
55.00
55.00
55.00
can you tell me why this must be happning?
Thanks
Bharat
but i have already tried this.
It is not coming the way i am looking for,.
o/p comes like this
2
5
555.00
5555.00
5555.00
55.00
55.00
55.00
can you tell me why this must be happning?
Thanks
Bharat
Do you give the same right coordinate of the rectangle in the draw string?
I think that draw string is not the best function :-(( It really aligns things in its own way..... But for this I think it should work....
I think that draw string is not the best function :-(( It really aligns things in its own way..... But for this I think it should work....
ASKER
Hi TheAvenger
I am specifying like this
x=50
for (i = 0; i <quantity.Length; i++)
{
y += 20;
g.DrawString(quantity[i],f ntAddress, br1,x + 600,y,objSF);
}
or is there any other way i can work with is....?
Thanks
Bharat
I am specifying like this
x=50
for (i = 0; i <quantity.Length; i++)
{
y += 20;
g.DrawString(quantity[i],f
}
or is there any other way i can work with is....?
Thanks
Bharat
OK, here's the problem: you give a POINT and not a RECTANGLE. Make it like this:
x=50
int width = 100;
int height = 20;
for (i = 0; i <quantity.Length; i++)
{
y += height;
g.DrawString(quantity[i],f ntAddress, br1, new RectangleF (x + 600, y, width, height), objSF);
}
x=50
int width = 100;
int height = 20;
for (i = 0; i <quantity.Length; i++)
{
y += height;
g.DrawString(quantity[i],f
}
ASKER
Thanks TheAvenger,
Even this i had tried but no luck.
Still it is not coming, the way it should as right aligned. Here only difference is spacing is changing between the numbers.
I don't know why it is changing the spacing.
Is there any other way....?
Thanks
Bharat
Even this i had tried but no luck.
Still it is not coming, the way it should as right aligned. Here only difference is spacing is changing between the numbers.
I don't know why it is changing the spacing.
Is there any other way....?
Thanks
Bharat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi TheAvenger
thank you for your immediate replies.
Sorry to disturb you again and again.
But the problem is I am using third party component and it has derived class from graphics class. So I have to use that only.
By looking at your code I am bit confused from where are you referring this e.Graphics.DrawString()
Can you please tell me what is this e is it System.EventArgs e or something else.
Let me explain you clear scenario. I am trying to build PDF and for this I am using PDF n more components provided by www.rarefind.com this component has graphics class. If I am not wrong they are using most of the methods as it is.
And few of them must have been modified. I have already told them about this. They are working on it.
If this problem is related to graphics class then I apologies my mistake to take your precious time.
Thank you once again
Bharat
thank you for your immediate replies.
Sorry to disturb you again and again.
But the problem is I am using third party component and it has derived class from graphics class. So I have to use that only.
By looking at your code I am bit confused from where are you referring this e.Graphics.DrawString()
Can you please tell me what is this e is it System.EventArgs e or something else.
Let me explain you clear scenario. I am trying to build PDF and for this I am using PDF n more components provided by www.rarefind.com this component has graphics class. If I am not wrong they are using most of the methods as it is.
And few of them must have been modified. I have already told them about this. They are working on it.
If this problem is related to graphics class then I apologies my mistake to take your precious time.
Thank you once again
Bharat
ASKER
If this problem is related to graphics class then I apologies my mistake to take your precious time.
By this line I mean www.rarefind.com's graphics class and not .NET's graphics class.
Thanks
Bharat
By this line I mean www.rarefind.com's graphics class and not .NET's graphics class.
Thanks
Bharat
The code I posted is from the Paint event of the control and the argument e is of type System.Windows.Forms.Paint EventArgs. It has the current control Graphics object as a property, so I can draw in the control directly using it. So I am drawing on the screen.
Unfortunately I cannot tell you anything about this third party control. I don't know if they use the default Graphics class or have overriden all methods :-((
Unfortunately I cannot tell you anything about this third party control. I don't know if they use the default Graphics class or have overriden all methods :-((
No problem for the time, that's why we participate in EE, to help each other find the problems and solutions for them.
StringFormat objSF = new StringFormat();
objSF.Alignment = Alignment.Far;
This should be all.