Skip to main content

How to: Create a Custom Search Panel

  • 2 minutes to read

This example demonstrates how to implement a custom search panel. Do this as follows:

Note

Refer to How to: Get a Bing Maps Key if you run the application and see a window with the following error message: “The specified Bing Maps key is invalid. To create a developer account, refer to https://www.microsoft.com/en-us/maps/create-a-bing-maps-key“.

View Example

using System;
using System.Windows.Forms;
using DevExpress.XtraMap;

namespace MapControl_SearchPanel {
    public partial class Form1 : Form {
        InformationLayer SearchLayer { get { return (InformationLayer)mapControl1.Layers["SearchLayer"]; } }
        BingSearchDataProvider SearchProvider { get { return (BingSearchDataProvider)SearchLayer.DataProvider; } }

        public Form1() {
            InitializeComponent();
            SearchLayer.DataRequestCompleted += SearchLayer_DataRequestCompleted;
        }

        void SearchLayer_DataRequestCompleted(object sender, RequestCompletedEventArgs e) {
            mapControl1.ZoomToFitLayerItems();
        }

        private void bSearch_Click(object sender, EventArgs e) {
            SearchProvider.Search(teKeyword.Text);
        }
    }
}