Back to Devexpress

NavigationPanelOptions.XCoordinatePattern Property

windowsforms-devexpress-dot-xtramap-dot-navigationpaneloptions-9200117d.md

latest5.9 KB
Original Source

NavigationPanelOptions.XCoordinatePattern Property

Gets or sets the pattern of the string representation of the X coordinate.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
[DefaultValue("")]
public string XCoordinatePattern { get; set; }
vb
<DefaultValue("")>
Public Property XCoordinatePattern As String

Property Value

TypeDefaultDescription
StringString.Empty

A string value that is the pattern.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to XCoordinatePattern
MapControl

.NavigationPanelOptions .XCoordinatePattern

|

Remarks

To specify the pattern for the Geographical coordinate, use the following predefined values.

PatternDescription
{CP}Displays a cardinal point.
{D:Number_of_decimal_places}Displays a degree value. The number of decimal places can be unspecified.
{M:Number_of_decimal_places}Displays a minute value. The number of decimal places can be unspecified.
{S:Number_of_decimal_places}Displays a second value. The number of decimal places can be unspecified.

To specify the pattern for the Cartesian coordinate, use the following predefined values.

PatternDescription
{F:Number_of_decimal_places}Displays a coordinate value. The number of decimal places can be unspecified.
{MU}Displays the abbreviation of measure unit name.

Example

This example demonstrates how to change the text of map point coordinates displayed in the navigation panel using latitude and longitude format patterns.

To do this, specify a string that will represent the pattern displayed within a coordinate label in the map navigation panel using NavigationPanelOptions.XCoordinatePattern and NavigationPanelOptions.YCoordinatePattern properties.

In this example, you can format the values of map point coordinates using a predefined list of patterns from the combo box. In the combo box, you can also specify a custom pattern using standard specifiers together with placeholders. For example: “{CP}{D}°{M}’{S:2}’’ “, where CP – is a cardinal point; D – is a degree; M - is a minute; S – is a second. Note that the precision specifier (“2”) indicates the desired number of decimal places.

csharp
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;

namespace MapCoordinatePatterns {

    public partial class Form1 : Form {

        string[] patterns = new string[] {
            "{D:1}°{CP}",
            "{CP}{D:6}°",
            "{D}°{M:2}\'{CP}",
            "{CP}{D}°{M:2}\'",
            "{D}°{M}\'{S:4}\'\'{CP}",            
            "{CP}{D}°{M}\'{S:4}\'\'",
            "Coordinates: {D}°{M}\'{S:2}\'\'{CP}"
        };

        public Form1() {
            InitializeComponent();
            PopulateComboBox(cbXCoordinatePattern);
            PopulateComboBox(cbYCoordinatePattern);
        }

        private void PopulateComboBox(ComboBoxEdit comboBox) {
            comboBox.Properties.Items.AddRange(patterns);
            comboBox.EditValue = comboBox.Properties.Items[0];
        }
        private void OnXCoordinatePatternSelectedIndexChanged(object sender, EventArgs e) {
            map.NavigationPanelOptions.XCoordinatePattern = cbXCoordinatePattern.EditValue as String;
        }

        private void OnYCoordinatePatternSelectedIndexChanged(object sender, EventArgs e) {
            map.NavigationPanelOptions.YCoordinatePattern = cbYCoordinatePattern.EditValue as String;
        }
    }
}
vb
Imports DevExpress.XtraEditors
Imports System
Imports System.Windows.Forms

Namespace MapCoordinatePatterns

    Partial Public Class Form1
        Inherits Form

        Private patterns() As String = { "{D:1}°{CP}", "{CP}{D:6}°", "{D}°{M:2}'{CP}", "{CP}{D}°{M:2}'", "{D}°{M}'{S:4}''{CP}", "{CP}{D}°{M}'{S:4}''", "Coordinates: {D}°{M}'{S:2}''{CP}" }

        Public Sub New()
            InitializeComponent()
            PopulateComboBox(cbXCoordinatePattern)
            PopulateComboBox(cbYCoordinatePattern)
        End Sub

        Private Sub PopulateComboBox(ByVal comboBox As ComboBoxEdit)
            comboBox.Properties.Items.AddRange(patterns)
            comboBox.EditValue = comboBox.Properties.Items(0)
        End Sub
        Private Sub OnXCoordinatePatternSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbXCoordinatePattern.SelectedIndexChanged
            map.NavigationPanelOptions.XCoordinatePattern = TryCast(cbXCoordinatePattern.EditValue, String)
        End Sub

        Private Sub OnYCoordinatePatternSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbYCoordinatePattern.SelectedIndexChanged
            map.NavigationPanelOptions.YCoordinatePattern = TryCast(cbYCoordinatePattern.EditValue, String)
        End Sub
    End Class
End Namespace

See Also

NavigationPanelOptions Class

NavigationPanelOptions Members

DevExpress.XtraMap Namespace