Poor Man’s Guide Lines for Visual Studio’s Windows Forms Editor


    The custom control I've been working on required drawing custom shapes on each side of the control.  The shapes needed to be the same size and I was sure that one was a couple of pixels shorter than the other, but it was difficult to tell with the naked eye.  I was wishing that the WinForms editor in VS 2008 had something like Photoshop's Guides: horizontal and vertical lines that can be placed over the image to aid alignment.




    Since the real issue was to create an edge that I could use to judge the length of my graphics, I pulled a panel on to the form and stretched it across the control.  That worked okay, but the panel was still 8 pixels high and I often had to move it when I resized my form or control.  The former was solved easily enough by setting the height of the panel to 1 in the Properties window, but now it was very difficult to get a grip on when I needed to move it.  Then it occurred to me that if I anchored the panel to the sides it would stretch as the form stretched.  Shazam!  Instant guidelines.


    At some point I'll write a macro to do this automagically, but this is good enough for now.


    If you find this useful, let me know.




DISCLAIMER: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer.

Comments (1)
  1. leppie says:

    You may want to fix the pixeloffset, so you get a crispy clear line as in the screenshot of the image editor above.

Comments are closed.

Skip to main content