myComboBox1.Map = _map;
using ESRI.ArcGIS.Carto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyGIS.Model
{
public class MyLayerComboBox : System.Windows.Forms.ComboBox
{
List<string> layers = new List<string>();
IMap map = null;
public IMap Map
{
get
{
return map;
}
set
{
//return;
map = value;
if (map == null) return;
layers = new List<string>();
for (int a = 0; a < map.LayerCount; a++)
{
layers.Add(map.Layer[a].Name);
}
DataSource = layers;
}
}
public ILayer Layer
{
get; set;
}
protected override void OnSelectedItemChanged(EventArgs e)
{
if (layers == null) return;
if (layers.Count == 0) return;
Layer = map.Layer[SelectedIndex];
}
protected override void OnSelectedValueChanged(EventArgs e)
{
if (layers == null) return;
if (layers.Count == 0) return;
Layer = map.Layer[SelectedIndex];
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// MyLayerComboBox
//
this.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ResumeLayout(false);
}
}
}