Create a new document 10 pixels wide and 1 pixel tall (or wider/thinner if you prefer) and choose the color you want your dashes to be. Using the Zoom Tool, get a close up of your document and draw a selection around all the pixels except for one on the right and one on the left. Press Option+Delete (PC: Alt+Delete) to fill the selection with your chosen color (see below zoomed-in example).
Next press Cmd+A (PC: Ctrl+A) to Select All and then choose Edit » Define Pattern, which will define the selected area as a reusable pattern in Photoshop. Choose a name for your pattern, such as “dashed line” and press OK.
Now that you’ve finished making your dashed line pattern, it’s time to apply it to whatever design you’d like. Either open up a preexisting image you’d like to add the line to, or create a new blank file to work with.
Make a new layer, and choose the Rectangular Marquee Tool.
Now, zoom in so you can get a closer look (well, unless your eyesight is a lot better than mine!) and then go ahead and draw a horizontal selection line on your image in the area you want your dashed line to appear. If you want a very thin dashed line, draw your selection to be 1-2px high… if you want a thicker dashed line, feel free to draw a taller selection. Your pattern will be “stacked” as many times as can fit into the height of your selection.
Go to Edit » Fill and choose Pattern from the dropdown—select your saved “dashed line” from the available Custom Patterns and press OK.
You can also make vertical dashes with a few more steps. Firstly you could easily draw a horizontal line and then rotate the layer 90 degrees (Edit » Transform » Rotate 90° CW).
Otherwise, to make an actual vertical pattern you can reuse, return to your original 10x1 dash pattern image and flip it 90 degrees (Image » Rotate Canvas » 90° CW). Sample the image as a patten again and use this new pattern to fill your vertical selection on your new file or preexisting image.
Yet another nifty idea to try is to make a circular selection instead of a line… give it a try and you’ll find yourself with a circle that’s been automatically filled with striped lines. Taking this yet another step further, try filling “any” shape (such as a star, triangle, etc). Have fun!