windowsforms-devexpress-dot-xtramap-dot-layerbase-a39c50c0.md
Occurs after the data has been loaded into a map layer.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
public event DataLoadedEventHandler DataLoaded
Public Event DataLoaded As DataLoadedEventHandler
The DataLoaded event's data class is DataLoadedEventArgs.
Handle the DataLoaded event to ensure that the data is loaded completely into a map layer.
This example shows how to visualize the progress of loading image tiles from the OpenStreetMap data provider using a progress bar.
To accomplish this task, handle the ImageLayer.RequestDataLoading event and specify how the progress bar should be updated using the UpdateProgressBar method. Then, handle the LayerBase.DataLoaded event to specify the final state of the progress bar when the data load is finished.
using DevExpress.XtraMap;
using System;
using System.Windows.Forms;
namespace TilesLoaded {
public partial class Form1 : Form {
int requestsCounter = 0;
ImageLayer Layer { get { return (ImageLayer)mapControl1.Layers[0]; } }
public Form1() {
InitializeComponent();
Layer.RequestDataLoading += Layer_RequestDataLoading;
Layer.DataLoaded += Layer_DataLoaded;
}
void Layer_RequestDataLoading(object sender, EventArgs e) {
requestsCounter++;
UpdateProgressBar();
}
void Layer_DataLoaded(object sender, DataLoadedEventArgs e) {
progressBar1.Value = 100;
progressBar1.Visible = false;
label1.Visible = false;
requestsCounter = 0;
}
void UpdateProgressBar() {
if (!progressBar1.Visible)
progressBar1.Visible = true;
if (!label1.Visible)
label1.Visible = true;
progressBar1.Value = (int)(100 * (requestsCounter - 1) / requestsCounter);
}
}
}
Imports DevExpress.XtraMap
Imports System
Imports System.Windows.Forms
Namespace TilesLoaded
Partial Public Class Form1
Inherits Form
Private requestsCounter As Integer = 0
Private ReadOnly Property Layer() As ImageLayer
Get
Return CType(mapControl1.Layers(0), ImageLayer)
End Get
End Property
Public Sub New()
InitializeComponent()
AddHandler Layer.RequestDataLoading, AddressOf Layer_RequestDataLoading
AddHandler Layer.DataLoaded, AddressOf Layer_DataLoaded
End Sub
Private Sub Layer_RequestDataLoading(ByVal sender As Object, ByVal e As EventArgs)
requestsCounter += 1
UpdateProgressBar()
End Sub
Private Sub Layer_DataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs)
progressBar1.Value = 100
progressBar1.Visible = False
label1.Visible = False
requestsCounter = 0
End Sub
Private Sub UpdateProgressBar()
If Not progressBar1.Visible Then
progressBar1.Visible = True
End If
If Not label1.Visible Then
label1.Visible = True
End If
progressBar1.Value = CInt(100 * (requestsCounter - 1) \ requestsCounter)
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the DataLoaded event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-map-customize-coordinate-systems-of-a-map/CS/CoordinateSystems/Form1.cs#L21
vectorLayer.Data = Adapter;
vectorLayer.DataLoaded += DataLayer_DataLoaded;
}
layer.ItemStyle.Fill = Color.FromArgb(40, 255, 128, 0);
layer.DataLoaded +=layer_DataLoaded;
mapControl1.Layers.Add(layer);
winforms-map-show-the-progress-of-loading-image-tiles/CS/TilesLoaded/Form1.cs#L13
Layer.RequestDataLoading += Layer_RequestDataLoading;
Layer.DataLoaded += Layer_DataLoaded;
}
winforms-map-load-data-from-a-sql-geometry-data-source/CS/SqlGeometry/Form1.cs#L26
};
layer.DataLoaded += layer_DataLoaded;
mapControl1.Layers.Add(layer);
winforms-map-customize-coordinate-systems-of-a-map/VB/CoordinateSystems/Form1.vb#L27
vectorLayer.Data = Adapter
AddHandler vectorLayer.DataLoaded, AddressOf DataLayer_DataLoaded
End Sub
layer.ItemStyle.Fill = Color.FromArgb(40, 255, 128, 0)
AddHandler layer.DataLoaded, AddressOf layer_DataLoaded
mapControl1.Layers.Add(layer)
winforms-map-show-the-progress-of-loading-image-tiles/VB/TilesLoaded/Form1.vb#L21
AddHandler Layer.RequestDataLoading, AddressOf Layer_RequestDataLoading
AddHandler Layer.DataLoaded, AddressOf Layer_DataLoaded
End Sub
winforms-map-load-data-from-a-sql-geometry-data-source/VB/SqlGeometry/Form1.vb#L25
Dim layer As DevExpress.XtraMap.VectorItemsLayer = New DevExpress.XtraMap.VectorItemsLayer() With {.Data = adapter, .ShapeTitlesPattern = "{TextCol}"}
AddHandler layer.DataLoaded, AddressOf Me.layer_DataLoaded
Me.mapControl1.Layers.Add(layer)
See Also