e.Graphics.DrawString

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    e.Graphics.DrawString

    Hello!

    If I use the DrawString below with object of StringFormat as the last object
    it works good.
    If I instead remove object StringFormat below as the last object of
    DrawString I get some rows that are not printed correctly.
    It's look like when toner is too low for the printer.This is only for some
    rows.
    Can somebody explain why this happens?
    What kind of StringFormat is used when this parameter is missing?


    private void printPage(objec t sender,
    System.Drawing. Printing.PrintP ageEventArgs e)
    {
    ....
    ....
    float leftMargin = e.MarginBounds. Left;
    float topMargin = e.MarginBounds. Top;
    float yPos = 0;
    Font printFont = new Font("Arial", 12);
    yPos = topMargin + printFont.GetHe ight(e.Graphics );
    e.HasMorePages = false;
    e.Graphics.Draw String(data.ToS tring(), printFont, Brushes.Black,
    leftMargin, yPos, new StringFormat()) ;
    }


  • Ignacio Machin ( .NET/ C# MVP )

    #2
    Re: e.Graphics.Draw String

    On Mar 26, 2:29 pm, "Tony Johansson" <johansson.ande rs...@telia.com >
    wrote:
    Hello!
    >
    If I use the DrawString below with object of StringFormat as the last object
    it works good.
    If I instead remove object StringFormat below as the last object of
    DrawString I get some rows that are not printed correctly.
    It's look like when toner is too low for the printer.This is only for some
    rows.
    Can somebody explain why this happens?
    What kind of StringFormat is used when this parameter is missing?
    >
    private void printPage(objec t sender,
    System.Drawing. Printing.PrintP ageEventArgs e)
    {
    ...
    ...
    float leftMargin = e.MarginBounds. Left;
    float topMargin  = e.MarginBounds. Top;
    float yPos = 0;
    Font printFont = new Font("Arial", 12);
    yPos = topMargin + printFont.GetHe ight(e.Graphics );
    e.HasMorePages = false;
    e.Graphics.Draw String(data.ToS tring(), printFont, Brushes.Black,
                                        leftMargin, yPos, new StringFormat()) ;
    >
    >
    >
    }- Hide quoted text -
    >
    - Show quoted text -
    Hi,

    Take alook at what the StringFormat provides.
    IMO you are just creating the default one, and I'm of the opinion that
    all the others overrides should use it as well.

    Are you using 2008? if so you can trace inside teh framework and see
    what is the differences between the different overloads versions.

    Comment

    • Tony Johansson

      #3
      Re: e.Graphics.Draw String

      Hello!

      I'm using VS05.

      So do you mean it's no point using this one with new StringFormat at the end
      "Graphics.DrawS tring(data.ToSt ring(), printFont, Brushes.Black, leftMargin,
      yPos, new StringFormat()) ;"
      because if I use this one without new StringFormat at the end
      Graphics.DrawSt ring(data.ToStr ing(), printFont, Brushes.Black,
      leftMargin, yPos);
      the .NET framework will use the default which is the one with new
      StringFormat.

      //Tony




      "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin @gmail.comskrev i
      meddelandet
      news:28b48b58-c2cc-40a1-b824-37feb4ac4f76@e3 9g2000hsf.googl egroups.com...
      On Mar 26, 2:29 pm, "Tony Johansson" <johansson.ande rs...@telia.com >
      wrote:
      Hello!
      >
      If I use the DrawString below with object of StringFormat as the last
      object
      it works good.
      If I instead remove object StringFormat below as the last object of
      DrawString I get some rows that are not printed correctly.
      It's look like when toner is too low for the printer.This is only for some
      rows.
      Can somebody explain why this happens?
      What kind of StringFormat is used when this parameter is missing?
      >
      private void printPage(objec t sender,
      System.Drawing. Printing.PrintP ageEventArgs e)
      {
      ...
      ...
      float leftMargin = e.MarginBounds. Left;
      float topMargin = e.MarginBounds. Top;
      float yPos = 0;
      Font printFont = new Font("Arial", 12);
      yPos = topMargin + printFont.GetHe ight(e.Graphics );
      e.HasMorePages = false;
      e.Graphics.Draw String(data.ToS tring(), printFont, Brushes.Black,
      leftMargin, yPos, new StringFormat()) ;
      >
      >
      >
      }- Hide quoted text -
      >
      - Show quoted text -
      Hi,

      Take alook at what the StringFormat provides.
      IMO you are just creating the default one, and I'm of the opinion that
      all the others overrides should use it as well.

      Are you using 2008? if so you can trace inside teh framework and see
      what is the differences between the different overloads versions.


      Comment

      Working...