Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Creating a Form dynamically in inches

Creating a Form dynamically in inches

Scheduled Pinned Locked Moved C#
helptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sindhutiwari
    wrote on last edited by
    #1

    Hi, My aim is to create a form in inches and to print it. i know the code for printing the form but the main problem is creating the form in inches as dimension if anyone knows how to do this please do let me know sindhu tiwari

    its me sid

    R P 2 Replies Last reply
    0
    • S sindhutiwari

      Hi, My aim is to create a form in inches and to print it. i know the code for printing the form but the main problem is creating the form in inches as dimension if anyone knows how to do this please do let me know sindhu tiwari

      its me sid

      R Offline
      R Offline
      Rich Insley
      wrote on last edited by
      #2

      The Graphics class provides two methods, Graphics.DpiX and Graphics.DpiY, that gives you the Dots-per-inch resolution of the Device Context:

      public void SetSize(float xInches, float yInches)
      {
      Graphics g = Graphics.FromHwnd(this.Handle);
      this.Size = new Size((int)(xInches * g.DpiX), (int)(yInches * g.DpiY));
      g.Dispose();
      }

      1 Reply Last reply
      0
      • S sindhutiwari

        Hi, My aim is to create a form in inches and to print it. i know the code for printing the form but the main problem is creating the form in inches as dimension if anyone knows how to do this please do let me know sindhu tiwari

        its me sid

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Assuming you're using WinForms, you can assume that there are 72 dots (pixels) per inch, so multiply up by 72.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        R 1 Reply Last reply
        0
        • P Pete OHanlon

          Assuming you're using WinForms, you can assume that there are 72 dots (pixels) per inch, so multiply up by 72.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          R Offline
          R Offline
          Rich Insley
          wrote on last edited by
          #4

          Pete O`Hanlon wrote:

          Assuming you're using WinForms, you can assume that there are 72 dots (pixels) per inch, so multiply up by 72.

          I think it's mostly 96 dpi these days.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups