i am trying to select features by querying two field as Plot_No (integer field ) and Layer(Text Field) but failed due to ArcMap crashing. i guess there might be problem at whereclause section. I couldnt figure out the solution. I am looking forward to your response. I am sure that your little effort can help me more.
amespace nayan1
{
public partial class Form1 : Form
{
IMxDocument mxd;
IFeatureLayer flayer;
IFeatureClass fclass;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
mxd = ArcMap.Application.Document as IMxDocument;
IMap map = mxd.FocusMap;
flayer = map.get_Layer(0) as IFeatureLayer;
fclass = flayer.FeatureClass;
IDataStatistics_Example(fclass);
}
private void button1_Click(object sender, EventArgs e)
{
mxd = ArcMap.Application.Document as IMxDocument;
IMap map = mxd.FocusMap;
flayer = map.get_Layer(0) as IFeatureLayer;
fclass = flayer.FeatureClass;
IFeatureSelection fsel = flayer as IFeatureSelection;
IQueryFilter qfilter = new QueryFilterClass();
qfilter.WhereClause = "Plot_No = textBox1.Text AND Layer =Convert.ToString( comboBox1.SelectedItem)";
fsel.SelectFeatures(qfilter, esriSelectionResultEnum.esriSelectionResultNew, false);
mxd.ActiveView.Refresh();
int x = map.SelectionCount;
if (x == 0)
{
MessageBox.Show("nothing is selected");
}
}
public void IDataStatistics_Example(IFeatureClass featureClass)
{
ICursor cursor = (ICursor)featureClass.Search(null, false);
IDataStatistics dataStatistics = new DataStatisticsClass();
dataStatistics.Field = "Layer";
dataStatistics.Cursor = cursor;
System.Collections.IEnumerator enumerator = dataStatistics.UniqueValues;
enumerator.Reset();
while (enumerator.MoveNext())
{
object myObject = enumerator.Current;
comboBox1.Items.Add(myObject);
}
Anyway, thanking You in Advance...
best regards
biswajit Saha