Back to Devexpress

ExportMapItemEventArgs.IsSelected Property

windowsforms-devexpress-dot-xtramap-dot-exportmapitemeventargs-f6882423.md

latest3.6 KB
Original Source

ExportMapItemEventArgs.IsSelected Property

Gets a value that indicates whether an exported map item is selected.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public bool IsSelected { get; }
vb
Public ReadOnly Property IsSelected As Boolean

Property Value

TypeDescription
Boolean

true if a map item is selected; otherwise, false.

|

Remarks

Use the IsSelected property to determine whether an exported map item is selected when handling the MapControl.ExportMapItem event.

Example

The following example demonstrates how to export selected map items to an image.

To do this, handle the MapControl.ExportMapItem event and set the ExportMapItemEventArgs.Cancel property to true if the map item is not selected (the ExportMapItemEventArgs.IsSelected property is set to false ). Then, call the MapControl.ExportToImage method using the map path (where the map image should be stored) and the specified image format (e.g., .png ).

csharp
using System;
using System.Windows.Forms;
using System.Drawing.Imaging;
using DevExpress.XtraMap;
using System.Diagnostics;

namespace ExportSelectedItems {
    public partial class Form1 : Form {
        string mapPath = "Image.png";

        public Form1() {
            InitializeComponent();
            mapControl1.ExportMapItem += mapControl1_ExportMapItem;
        }

        private void mapControl1_ExportMapItem(object sender, ExportMapItemEventArgs e) {
            if (!e.IsSelected)
                e.Cancel = true;
        }

        private void simpleButton1_Click(object sender, EventArgs e) {
            mapControl1.ExportToImage(mapPath, ImageFormat.Png);
            Process.Start(mapPath);
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports System.Drawing.Imaging
Imports DevExpress.XtraMap
Imports System.Diagnostics

Namespace ExportSelectedItems
    Partial Public Class Form1
        Inherits Form

        Private mapPath As String = "Image.png"

        Public Sub New()
            InitializeComponent()
            AddHandler mapControl1.ExportMapItem, AddressOf mapControl1_ExportMapItem
        End Sub

        Private Sub mapControl1_ExportMapItem(ByVal sender As Object, ByVal e As ExportMapItemEventArgs)
            If Not e.IsSelected Then
                e.Cancel = True
            End If
        End Sub

        Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles simpleButton1.Click
            mapControl1.ExportToImage(mapPath, ImageFormat.Png)
            Process.Start(mapPath)
        End Sub
    End Class
End Namespace

See Also

ExportMapItemEventArgs Class

ExportMapItemEventArgs Members

DevExpress.XtraMap Namespace