In This Topic
    Guidelines
    In This Topic
    Guidelines are infinite lines, which help you better align and reposition the content of a drawing. Currently there are two types of guidelines - horizontal and vertical - represented by the NHorizontalGuideline and NVerticalGuideline classes respectively. They both derive from the base NGuideline abstract class.

    The guidelines of a drawing are contained in an instance of the NGuidelineCollection class, an instance of which can be obtained from the Guidelines property of the NDrawingDocument class.
     Creating guidelines

    The following code adds a horizontal and a vertical guideline to a drawing document:

    C#
    Copy Code
    // create a horizontal guideline with Y coordinate 20 (in scene units)
    NHorizontalGuideline hguide =  new NHorizontalGuideline(20); 
    drawingDocument.Guidelines.AddChild(hguide); 
    
    // create a vertical guideline with X coordinate 30 (in scene units)
    NVerticalGuideline vguide =  new NVerticalGuideline(20);
    drawingDocument.Guidelines.AddChild(vguide);
    
    Visual Basic
    Copy Code
    ' create a horizontal guideline with Y coordinate 20 (in scene units)
    Dim hguide As New NHorizontalGuideline(20) 
    drawingDocument.Guidelines.AddChild(hguide) 
    
    ' create a vertical guideline with X coordinate 30 (in scene units) 
    Dim vguide As New NVerticalGuideline(20)
    drawingDocument.Guidelines.AddChild(vguide)
    
     Global guidelines visibility

    The guidelines global visibility can be controlled by the ShowGuidelines property of the NGlobalVisibility attribute. An instance of this attribute can be obtained from the GlobalVisibility property of the NDrawingView class. For example the following code will hide all guidelines in the specified view:

    C#
    Copy Code
    // do not display the guidelines in this view
    drawingView.GlobalVisibility.ShowGuidelines = false;
    
    Visual Basic
    Copy Code
    ' do not display the guidelines in this view
    drawingView.GlobalVisibility.ShowGuidelines = False
    
     Related Examples
    Windows Forms: View & Designer - Designer - Snapping 
    See Also