Each view has two rulers - horizontal and vertical, which are represented by instances of the NHorizontalRuler and NVerticalRuler classes respectively. They both derive from the base NRuler class (on its turn derived from NViewComponent).
You can obtain a reference to the horizontal ruler via the HorizontalRuler property. Analogously a reference to the vertical ruler is obtained from the VerticalRuler property:
C# |
Copy Code
|
---|---|
// get the horizontal and the vertical ruler
NHorizontalRuler hruler = view.HorizontalRuler;
NVerticalRuler vruler = view.VerticalRuler;
|
Visual Basic |
Copy Code
|
---|---|
' get the horizontal and the vertical ruler Dim hruler As NHorizontalRuler = view.HorizontalRuler Dim vruler As NVerticalRuler = view.VerticalRuler |
Rulers display major and minor ticks. There is a fixed number of minor ticks displayed between two major ones, which is controlled by the MinorTicksCount property. The value from which the major ticks originate is called origin and is controlled by the Origin property and is specified in the ruler unit of measure.
The step of the major ticks can be determined in several modes. The major ticks step mode is controlled by the MajorTicksStepMode property, which can accept one of the following values:
The following code makes a fixed ruler with major tick step 50 in the current ruler measurement unit and displays 6 minor ticks between the major ones.
C# |
Copy Code
|
---|---|
// change the major ticks step mode ruler.MajorTicksStepMode = AutoStepMode.Fixed; ruler.FixedMajorTicksStep = 50; // change the number of minor ticks ruler.MinorTicksCount = 6; |
Visual Basic |
Copy Code
|
---|---|
' change the major ticks step mode ruler.MajorTicksStepMode = AutoStepMode.Fixed ruler.FixedMajorTicksStep = 50 ' change the number of minor ticks ruler.MinorTicksCount = 6 |
You can also control the minor ticks length as well as the major and minor ticks color with the help of the MinorTicksLength, MajorTicksColor and MinorTicksColor properties respectively.
Ruler texts are displayed for the values of the major ticks. Ruler texts are displayed with the font specified by the TextFontStyle property and with format defined by the TextFormat property. The text color is analogously controlled by the TextColor property. The following code alters the texts font, color and format:
C# |
Copy Code
|
---|---|
// alter the ruler text font, color and format ruler.TextFontStyle = new NFontStyle("Tahoma", 10); ruler.TextColor = Color.Red; ruler.TextFormat = "0.##"; |
Visual Basic |
Copy Code
|
---|---|
' alter the ruler text font, color and format ruler.TextFontStyle = New NFontStyle("Tahoma", 10) ruler.TextColor = Color.Red ruler.TextFormat = "0.##" |