Question

Does anyone have a good technique (or tutorial) to implement rulers within a C# Windows Forms application? I want to display an image while showing rulers that indicate your mouse position to allow a more accurate positioning of the cursor. Just like the image below:

Ruler depicting where the cursor is located.

I tried using splitter controls to hold the tick marks but I don't know how to make the top-left the gray blank area. Any advice? Thanks.

Was it helpful?

Solution

I'd built a custom control to do this in both X and Y location, and use two controls.

The control would have to override Paint() and use GDI methods to display the tick marks, it would then capture mouse events and update locations appropriately.

OTHER TIPS

This is the best article I've found and used on the matter: http://www.codeproject.com/KB/miscctrl/ruler.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top