Results 1 to 12 of 12

Thread: set distance between two pictureboxes in millimeters.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    82

    set distance between two pictureboxes in millimeters.

    Hello
    I have two pictureboxes and I want them to be placed 5 millimeters away from each other. How can I do that?
    Thanks

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: set distance between two pictureboxes in millimeters.

    How you define 5mm on a Form? Or are you talking about a printed page?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    82

    Re: set distance between two pictureboxes in millimeters.

    On a printed page.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: set distance between two pictureboxes in millimeters.

    If you're talking about on a form on screen then you'd have to consider the DPI of the monitor, but what if someone has multiple monitors at different DPIs? What if they move the form between those monitors? What if the form straddles two monitors? What if the user changes the resolution?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: set distance between two pictureboxes in millimeters.

    Quote Originally Posted by bruel1999 View Post
    On a printed page.
    In that case they're not PictureBoxes, they're just images drawn on the printing surface.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    82

    Re: set distance between two pictureboxes in millimeters.

    Quote Originally Posted by jmcilhinney View Post
    In that case they're not PictureBoxes, they're just images drawn on the printing surface.
    I meant, when printed, the two pictureboxes should be 5 mm apa

    If you're talking about on a form on screen then you'd have to consider the DPI of the monitor, but what if someone has multiple monitors at different DPIs? What if they move the form between those monitors? What if the form straddles two monitors? What if the user changes the resolution?
    Let's assume only one computer will be used.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: set distance between two pictureboxes in millimeters.

    Quote Originally Posted by bruel1999 View Post
    I meant, when printed, the two pictureboxes should be 5 mm apa
    But that's the point I was making: you're not printing PictureBoxes, you're printing Images. Your original question should have asked how to print two Images 5mm apart. Even if the Images are displayed in PictureBoxes on a form, those PictureBoxes are still not relevant to the printing part.

    Unfortunately, I can only help with the terminology. I've not done a great deal of printing so I'm no expert. I'd assume that it would have something to do with the DPI setting of the printer, but I was unable to find anything relevant when I looked through the classes that I know get used in GDI+ printing, e.g. PrinterSettings and PageSettings.

    Merrion is our local printing expert so it might not be a bad idea to send him a PM and provide a link to this thread. He usually replies to questions on printing but he's not going to realise that this thread is about printing without reading it, which he probably won't do without knowing that it's about printing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    82

    Re: set distance between two pictureboxes in millimeters.

    Merrion is our local printing expert so it might not be a bad idea to send him a PM and provide a link to this thread.
    okay, I'll do that

  9. #9
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: set distance between two pictureboxes in millimeters.

    Graphics measurements in printing are in tenths of a millimetre - e.g., to print a rectangle 4 x 5 centimetres, you would use e.Graphics.DrawRectangle(Pens.Black, 10, 10, 4000, 5000)


    To do this for a picture, use the Graphics.DrawImage overload that takes a x,y, width and height. If it is not the same aspect ratio as the source image it will be stretched/squashed to fit.

    See also the Guide to printing in .NET

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: set distance between two pictureboxes in millimeters.

    Quote Originally Posted by Merrion View Post
    Graphics measurements in printing are in tenths of a millimetre
    Huh, I didn't know that. That does make it easy.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: set distance between two pictureboxes in millimeters.

    Quote Originally Posted by Merrion View Post
    Graphics measurements in printing are in tenths of a millimetre - e.g., to print a rectangle 4 x 5 centimetres, you would use [B]e.Graphics.DrawRectangle(Pens.Black, 10, 10, 4000, 5000)
    ...
    Your example would seem to indicate hundredths of a millimetre.
    There are 10 millimeters in a centimeter, and 1/10th of a millimeter would mean 100 printing units per centimeter, so 4 centimeters would be 400 printing units (400 tenths of a millimeter), not 4000. If 1000 is the correct number for 1 centimeter, then there would be 100 units per 1 mm, not 10.
    Last edited by passel; Oct 3rd, 2014 at 05:22 AM.

  12. #12
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: set distance between two pictureboxes in millimeters.

    Oops - yeah, my maths is terrible.

Tags for this Thread

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