问题描述
publicpartialclassattribute:Form{privateILayerlayer;publicattribute(ILayerlyr){InitializeComponent();layer=lyr;//this.Text="""+layer.Name+""属性表";}privatevoidattribute_Load(objectsender,EventArgse){//try{ITablelyrtable=(ITable)layer;DataTabletable=newDataTable();IFieldfield;for(inti=0;i<lyrtable.Fields.FieldCount;i++){field=lyrtable.Fields.get_Field(i);table.Columns.Add(field.Name);}object[]values=newobject[lyrtable.Fields.FieldCount];IQueryFilterqueryFilter=newQueryFilter();ICursorcursor=lyrtable.Search(queryFilter,true);IRowrow;while((row=cursor.NextRow())!=null){for(intj=0;j<lyrtable.Fields.FieldCount;j++){objectob=row.get_Value(j);values[j]=ob;}table.Rows.Add(values);}this.dataGridView1.DataSource=table;}//catch//{//MessageBox.Show("无法显示属性表!");//this.Close();}}无法打开属性变问题在这行代码for(inti=0;i<lyrtable.Fields.FieldCount;i++);提示未将对象引用设置到对象的实例。求解答