Results 1 to 4 of 4

Thread: VB10 Form width in inches

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    5

    VB10 Form width in inches

    How can I set the width of a form in inches (or cm) instead of pixels?

    I want to print the form, so it needs to always be the same dimensions (4" by 6"). I saw some examples for previous versions of VB, but nothing that works in VB10.

    Thanks,
    Alex

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: VB10 Form width in inches

    here's how to set it in inches:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Dim gr As Graphics = Me.CreateGraphics
    5.         Me.SetClientSizeCore(CInt(4 * gr.DpiX), CInt(6 * gr.DpiY)) '4 by 6 (w by h)
    6.     End Sub
    7.  
    8. End Class

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: VB10 Form width in inches

    for cm: 1 inch = 2.54 cm

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    5

    Re: VB10 Form width in inches

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width