Back to Devexpress

DataSourceAdapterBase.DataSource Property

windowsforms-devexpress-dot-xtramap-dot-datasourceadapterbase.md

latest7.7 KB
Original Source

DataSourceAdapterBase.DataSource Property

Specifies the data source to provide data for a data adapter.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
[DefaultValue(null)]
public object DataSource { get; set; }
vb
<DefaultValue(Nothing)>
Public Property DataSource As Object

Property Value

TypeDefaultDescription
Objectnull

A Object.

|

Example

This example demonstrates how to generate bubble charts for a map control. Do the following:

csharp
// Specify data for the bubble layer.
    BubbleLayer.Data = CreateData();
private IMapDataAdapter CreateData() {
    BubbleChartDataAdapter adapter = new BubbleChartDataAdapter() {
        DataSource = LoadData(),
        MeasureRules = CreateMeasureRules(),
        ItemMaxSize = 60,
        ItemMinSize = 10
    };

    #region #Mappings
    // Map the properties of chart items to the appropriate fields in the data source.
    adapter.Mappings.Latitude = "glat";
    adapter.Mappings.Longitude = "glon";
    adapter.Mappings.Value = "mag";
    #endregion #Mappings

    // Create attribute mappings to provide additional information about map items to the map.
    adapter.AttributeMappings.Add(new MapItemAttributeMapping("Magnitude", "mag"));
    adapter.AttributeMappings.Add(new MapItemAttributeMapping("Year", "yr"));
    adapter.AttributeMappings.Add(new MapItemAttributeMapping("Month", "mon"));
    adapter.AttributeMappings.Add(new MapItemAttributeMapping("Day", "day"));
    adapter.AttributeMappings.Add(new MapItemAttributeMapping("Depth", "dep"));

    return adapter;
}

private DataTable LoadData() {
    DataSet ds = new DataSet();
    ds.ReadXml(dataPath);
    DataTable dt = ds.Tables[0];
    dt.DefaultView.RowFilter = string.Format(CultureInfo.InvariantCulture, "(mag >= {0}) AND (mag <= {1})", minMagnitude, maxMagnitude);

    return ds.Tables[0];
}

private MeasureRules CreateMeasureRules() {
    MeasureRules measureRules = new MeasureRules();

    measureRules.ApproximateValues = true;
    measureRules.RangeDistribution = new LinearRangeDistribution();

    for (int i = minMagnitude; i < maxMagnitude; i++) {
        measureRules.RangeStops.Add(i);
    }

    return measureRules;
}
vb
' Specify data for the bubble layer.
    BubbleLayer.Data = CreateData()
Private Function CreateData() As IMapDataAdapter
    Dim adapter As New BubbleChartDataAdapter() With {.DataSource = LoadData(), .MeasureRules = CreateMeasureRules(), .ItemMaxSize = 60, .ItemMinSize = 10}

    ' #Region "#Mappings"
    ' Map the properties of chart items to the appropriate fields in the data source.
    adapter.Mappings.Latitude = "glat"
    adapter.Mappings.Longitude = "glon"
    adapter.Mappings.Value = "mag"

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource property.

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-bind-to-xml-data/CS/WinForms_MapControl_ListAdapter/Form1.cs#L52

csharp
adapter.DataSource = source;

winforms-map-customize-mini-map-layers/CS/MiniMapLayers/Form1.cs#L94

csharp
ListSourceDataAdapter adapter = new ListSourceDataAdapter();
adapter.DataSource = data;
adapter.Mappings.Latitude = "Latitude";

winforms-map-aggregate-vector-items-using-a-clusterer/CS/ClustererSample/Form1.cs#L19

csharp
private void Form1_Load(object sender, EventArgs e) {
    DataAdapter.DataSource = LoadData();
    DistanceBasedClusterer clusterer = new DistanceBasedClusterer {

winforms-map-bind-to-xml-data/VB/WinForms_MapControl_ListAdapter/Form1.vb#L39

vb
Dim adapter As ListSourceDataAdapter = New ListSourceDataAdapter()
adapter.DataSource = source
adapter.Mappings.Latitude = "Latitude"

winforms-map-customize-mini-map-layers/VB/MiniMapLayers/Form1.vb#L70

vb
Dim adapter As DevExpress.XtraMap.ListSourceDataAdapter = New DevExpress.XtraMap.ListSourceDataAdapter()
adapter.DataSource = data
adapter.Mappings.Latitude = "Latitude"

winforms-map-aggregate-vector-items-using-a-clusterer/VB/ClustererSample/Form1.vb#L31

vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    DataAdapter.DataSource = LoadData()
    Dim clusterer As DistanceBasedClusterer = New DistanceBasedClusterer With {.ItemMaxSize = 60, .ItemMinSize = 14, .GroupProvider = New AttributeGroupProvider With {.AttributeName = "LocationName"}}

See Also

DataSourceAdapterBase Class

DataSourceAdapterBase Members

DevExpress.XtraMap Namespace