ListBox框中显示shp文件图层中所有字段的名称(50分)

  • 主题发起人 vbkiller
  • 开始时间
V

vbkiller

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在listbox框中实现把shp文件中的所有字段都显示
程序如下
var
oFild :IMOField;
oFilds:IMOFields;
i :integer;
lys :IMOLayers;
ly :IMOMapLayer;
recs :IMORecordset;
begin

//lys :=IMOLayers(CreateOleObject('MapObjects2.Layers'));
//只要加上上句运行到下句就报错,为何?
lys :=Map1.Layers;
ly :=IMOMapLayer(CreateOleObject('MapObjects2.MapLayer'));
ly :=IMOMapLayer(lys.Item(0));
recs :=ly.Records;
oFilds :=recs.Fields;
for i :=0 to oFilds.Count -1do

begin

oFild :=oFilds.Item(i);
//执行到这句就抱错
ListBox1.Items.Add(oFild.Name);
//这句同样报错
ListBox1.AddItem(oFild.Name,self);
end;

end;
 
顶部