ArcEngine中如何选择属性表里的某一列并加到combobox控件中?
我的代码如下。可是却不知道那里错了,希望各位不吝赐教。谢谢了先。。privatevoidQueryStation_Click(objectsender,EventArgs...
我的代码如下。可是却不知道那里错了,希望各位不吝赐教。谢谢了先。。
private void QueryStation_Click(object sender, EventArgs e)
{
int i,j;
string sName = "Station";
//string SName = "站点名称";
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer = ChooseObject(ref sName) as IFeatureLayer;//参数必须与ref一起传递
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IQueryFilter pQueryFilter;
pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "站点名称 like'*'";
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pQueryFilter ,false);
IFeature pFeature = pFeatureCursor.NextFeature();
i = pFeature.Fields.FieldCount;
if (pFeature != null)
{
for(j=0;j<i;j++)
{
string featurename = pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature = pFeatureCursor.NextFeature();
}
} 展开
private void QueryStation_Click(object sender, EventArgs e)
{
int i,j;
string sName = "Station";
//string SName = "站点名称";
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer = ChooseObject(ref sName) as IFeatureLayer;//参数必须与ref一起传递
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IQueryFilter pQueryFilter;
pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "站点名称 like'*'";
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pQueryFilter ,false);
IFeature pFeature = pFeatureCursor.NextFeature();
i = pFeature.Fields.FieldCount;
if (pFeature != null)
{
for(j=0;j<i;j++)
{
string featurename = pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature = pFeatureCursor.NextFeature();
}
} 展开
2个回答
展开全部
if (pFeature != null) //这里不能用if对吧?试试whlie
{
for(j=0;j<i;j++)
{
string featurename = pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature = pFeatureCursor.NextFeature();
}
//还有点疑问,pFeature.get_Value(j).ToString()=null的时候,pFeature应该不为空的,不过你可以测试下。
{
for(j=0;j<i;j++)
{
string featurename = pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature = pFeatureCursor.NextFeature();
}
//还有点疑问,pFeature.get_Value(j).ToString()=null的时候,pFeature应该不为空的,不过你可以测试下。
展开全部
if
(pFeature
!=
null)
//这里不能用if对吧?试试whlie
{
for(j=0;j<i;j++)
{
string
featurename
=
pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature
=
pFeatureCursor.NextFeature();
}
//还有点疑问,pFeature.get_Value(j).ToString()=null的时候,pFeature应该不为空的,不过你可以测试下。
(pFeature
!=
null)
//这里不能用if对吧?试试whlie
{
for(j=0;j<i;j++)
{
string
featurename
=
pFeature.get_Value(j).ToString();
comboBox1.Items.Add(featurename);
}
pFeature
=
pFeatureCursor.NextFeature();
}
//还有点疑问,pFeature.get_Value(j).ToString()=null的时候,pFeature应该不为空的,不过你可以测试下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询