Printing offers and bills

I am coding a application that should create and print offers and bills for a small company. Creating is no problem, but I did not find a solution for printing several data in columns.

The table should look like this:

Pos    scores    description     price    price

01      4           [desc]            1€       4€
02      2           [desc]            4        8€

etc.

does sb. have an idea how to format the data in order to print it 
May be a 3rd party control oder something else.


Thanks in advance
M<@>S


Answer this question

Printing offers and bills

  • julo

    Oops I remembered I coded the right adjustments myself here it is:


    private void drawText(Graphics g,Pen pen,Font fnt,Brush brush,PointF p,int posit,string s)
    {
    StringFormat fmt = new StringFormat();
    float shft = ((posit > 10)   1.0f : 0.0f);
    posit = posit % 10;
    if (posit == 1 || posit == 2 || posit == 3)
    p.X += shft;
    else if (posit == 4 || posit == 5 || posit == 6)
    p.X -= 0.5f * g.MeasureString(s,fnt).Width;
    else if (posit == 7 || posit == 8 || posit == 9)
    p.X -= g.MeasureString(s,fnt).Width + shft;
    if (posit == 1 || posit == 4 || posit == 7)
    p.Y -= fnt.Height + shft;
    else if (posit == 2 || posit == 5 || posit == 8)
    p.Y -= 0.5f * fnt.Height;
    else if (posit == 3 || posit == 6 || posit == 9)
    p.Y += shft;
    fmt.Alignment = StringAlignment.Near;
    fmt.LineAlignment = StringAlignment.Near;
    g.DrawString(s,fnt,brush,p.X,p.Y,fmt);
    }


    The code above mimics the hp hpgl-positioning codes and offers 18 ways to position text.
    For this to work you of course needs to feed your columns seperately to this routine, as far as I know you can't expect columns to line up properly using a single string, as sugested in the previous posting.

  • The YoYoMan

    how about:


    public override string ToString()
    {
    char euro = '\hexnumber'; // though I am european I haven't a clue what unicode
    string str = col1.ToString("2d") + "\t" +col2.ToString() + "[desc]" + col4.ToString() + euro + col5.ToString() + euro;
    return str;
    }


    checkout NumberFormatInfo class, it ought to be possible to rightalign your numbers but I haven't done that yet, so I dont know how. other then some elaborate coding using the MeasureString method of the graphics class.

    hope this helps

  • Sorpor

    thanks, I hope it will work
  • Printing offers and bills