利用地图图层的属性项填充下拉列表
private void FillDropDown(string tableName, string colName,string startPoint, string startPointName)
{
MapInfo.Mapping.Map map = null;
if (MapInfo.Engine.Session.Current.MapFactory.Count == 0||(map = MapInfo.Engine.Session.Current.MapFactory[0]) == null)
{
return;
}
DropDownList2.Items.Clear();
MapInfo.Mapping.FeatureLayer fl2 = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName];
MapInfo.Data.Table t2 = fl2.Table;
MIDataReader tr2;
MIConnection con2 = new MIConnection();
MICommand tc2 = con2.CreateCommand();
tc2.CommandText = "select " + colName + " from " + t2.Alias ;
con2.Open();
tr2 = tc2.ExecuteReader() ;
while (tr2.Read())
{
DropDownList2.Items.Add(tr2.GetString(0));
}
tc2.Cancel();
tc2.Dispose();
tr2.Close() ;
con2.Close();
DropDownList1.Items.Clear();
MapInfo.Mapping.FeatureLayer fl1 = (MapInfo.Mapping.FeatureLayer)map.Layers[startPoint];
MapInfo.Data.Table t1 = fl1.Table;
MIDataReader tr1;
MIConnection con1= new MIConnection();
MICommand tc1 = con1.CreateCommand();
tc1.CommandText = "select " + startPointName + " from " + t1.Alias ;
con1.Open();
tr1 = tc1.ExecuteReader() ;
while (tr1.Read())
{
DropDownList1.Items.Add(tr1.GetString(0));
}
tc1.Cancel();
tc1.Dispose();
tr1.Close();
con1.Close();
}
{
MapInfo.Mapping.Map map = null;
if (MapInfo.Engine.Session.Current.MapFactory.Count == 0||(map = MapInfo.Engine.Session.Current.MapFactory[0]) == null)
{
return;
}
DropDownList2.Items.Clear();
MapInfo.Mapping.FeatureLayer fl2 = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName];
MapInfo.Data.Table t2 = fl2.Table;
MIDataReader tr2;
MIConnection con2 = new MIConnection();
MICommand tc2 = con2.CreateCommand();
tc2.CommandText = "select " + colName + " from " + t2.Alias ;
con2.Open();
tr2 = tc2.ExecuteReader() ;
while (tr2.Read())
{
DropDownList2.Items.Add(tr2.GetString(0));
}
tc2.Cancel();
tc2.Dispose();
tr2.Close() ;
con2.Close();
DropDownList1.Items.Clear();
MapInfo.Mapping.FeatureLayer fl1 = (MapInfo.Mapping.FeatureLayer)map.Layers[startPoint];
MapInfo.Data.Table t1 = fl1.Table;
MIDataReader tr1;
MIConnection con1= new MIConnection();
MICommand tc1 = con1.CreateCommand();
tc1.CommandText = "select " + startPointName + " from " + t1.Alias ;
con1.Open();
tr1 = tc1.ExecuteReader() ;
while (tr1.Read())
{
DropDownList1.Items.Add(tr1.GetString(0));
}
tc1.Cancel();
tc1.Dispose();
tr1.Close();
con1.Close();
}