利用地图图层的属性项填充下拉列表

 

None.gif private   void  FillDropDown( string  tableName,  string  colName, string  startPoint,  string  startPointName) 
ExpandedBlockStart.gifContractedBlock.gif        
{
InBlock.gif            MapInfo.Mapping.Map map 
= null;
InBlock.gif
InBlock.gif            
if (MapInfo.Engine.Session.Current.MapFactory.Count == 0||(map = MapInfo.Engine.Session.Current.MapFactory[0]) == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            DropDownList2.Items.Clear();
InBlock.gif            MapInfo.Mapping.FeatureLayer fl2 
= (MapInfo.Mapping.FeatureLayer)map.Layers[tableName];
InBlock.gif            MapInfo.Data.Table  t2 
= fl2.Table;
InBlock.gif            MIDataReader tr2;
InBlock.gif            MIConnection con2 
= new MIConnection();
InBlock.gif            MICommand tc2 
= con2.CreateCommand();
InBlock.gif            tc2.CommandText 
= "select " + colName + " from " + t2.Alias ;
InBlock.gif            con2.Open();
InBlock.gif            tr2 
= tc2.ExecuteReader() ;
InBlock.gif            
while (tr2.Read()) 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
InBlock.gif                DropDownList2.Items.Add(tr2.GetString(
0));
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            tc2.Cancel();
InBlock.gif            tc2.Dispose();
InBlock.gif            tr2.Close() ;
InBlock.gif            con2.Close();
InBlock.gif
InBlock.gif            DropDownList1.Items.Clear();
InBlock.gif            MapInfo.Mapping.FeatureLayer fl1 
= (MapInfo.Mapping.FeatureLayer)map.Layers[startPoint];
InBlock.gif            MapInfo.Data.Table  t1 
= fl1.Table;
InBlock.gif            MIDataReader tr1;
InBlock.gif            MIConnection con1
= new MIConnection();
InBlock.gif            MICommand tc1 
= con1.CreateCommand();
InBlock.gif            tc1.CommandText 
= "select " + startPointName + " from " + t1.Alias ;
InBlock.gif            con1.Open();
InBlock.gif            tr1 
= tc1.ExecuteReader() ;
InBlock.gif            
while (tr1.Read()) 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
InBlock.gif                DropDownList1.Items.Add(tr1.GetString(
0));
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            tc1.Cancel();
InBlock.gif            tc1.Dispose();
InBlock.gif            tr1.Close();
InBlock.gif            con1.Close();
InBlock.gif
ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/yuxon/archive/2006/06/28/437507.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值