Sneha,
I understood your mean exactly, here is the code snippet for you below:
private void SqlQuery_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\USStates.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.LineJoin = DrawingLineJoin.Round;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("WorldLayer", worldLayer);
winformsMap1.Overlays.Add(staticOverlay);
InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();
highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkGreen));
LayerOverlay highlightOverlay = new LayerOverlay();
highlightOverlay.Layers.Add("HighlightLayer", highlightLayer);
winformsMap1.Overlays.Add("HighlightOverlay", highlightOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-165.7421875, 80.23046875, -35.6640625, 13.08203125);
winformsMap1.Refresh();
worldLayer.Open();
DataTable dataTable = worldLayer.QueryTools.ExecuteQuery("Select * from USStates Where PERIMETER > 30 Order by PERIMETER");
worldLayer.Close();
dgridResult.DataSource = dataTable;
}
private void dgridResult_SelectionChanged(object sender, EventArgs e)
{
DataGridView view = sender as DataGridView;
DataGridViewRow row = view.CurrentRow;
FeatureLayer worldLayer = winformsMap1.FindFeatureLayer("WorldLayer");
InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("HighlightLayer");
worldLayer.Open();
Feature feature = worldLayer.QueryTools.GetFeatureById(row.Cells["RecID"].Value.ToString(), ReturningColumnsType.AllColumns);
worldLayer.Close();
highlightLayer.InternalFeatures.Clear();
highlightLayer.InternalFeatures.Add(row.Cells["RecID"].Value.ToString(), feature);
winformsMap1.Refresh(winformsMap1.Overlays["HighlightOverlay"]);
}
This is just a sample for you, you need to reference the USStates.shp to run the sample properly,
Thanks,
Scott,