private void PopulateFlexGrids(DataGridView pDataGrid, ARFeatureSet arFeatureSet) { //Get first feature in ARFeatureSet arFeatureSet.Reset(); ARFeature arFeature = arFeatureSet.Next(); //Exit if no features in set if (arFeature == null) { return; } //Change cursor while grid populates Cursor = Cursors.WaitCursor; //Clear Grid of any existing data pDataGrid.Rows.Clear(); //Loop through and add field names for (int i = 0; i < arFeature.FieldCount; i++) { pDataGrid.Columns.Add(arFeature.get_FieldName(i), arFeature.get_FieldName(i)); } //add values object[] values = new object[arFeature.FieldCount]; //Populate Grid while (arFeature != null) { for (int i = 0; i < arFeature.FieldCount; i++) { values[i] = ARFeatureValueAsString(arFeature, i); } pDataGrid.Rows.Add(values); //Move to next Feature in the FeatureSet arFeature = arFeatureSet.Next(); } //Reset mouse cursor Cursor = Cursors.Default; }
private void PopulateFlexGrids(DataGridView pDataGrid, ARFeatureSet arFeatureSet) { //Get first feature in ARFeatureSet arFeatureSet.Reset(); ARFeature arFeature = arFeatureSet.Next(); //Exit if no features in set if (arFeature == null) { return; } //Change cursor while grid populates Cursor = Cursors.WaitCursor; //Clear Grid of any existing data pDataGrid.Rows.Clear(); //Loop through and add field names for (int i = 0; i < arFeature.FieldCount; i++) { pDataGrid.Columns.Add(arFeature.get_FieldName(i), arFeature.get_FieldName(i)); } //add values object[] values = new object[arFeature.FieldCount]; //Populate Grid while (arFeature != null) { for (int i = 0; i < arFeature.FieldCount; i++) { values[i] = ARFeatureValueAsString(arFeature, i); } pDataGrid.Rows.Add(values); //Move to next Feature in the FeatureSet arFeature = arFeatureSet.Next(); } //Reset mouse cursor Cursor = Cursors.Default; }
private void cmdQuery_Click(object sender, System.EventArgs e) { //Set mouse cursor as this can take some time with large datasets Cursor.Current = Cursors.WaitCursor; //Check value has been entered in field combo if (cboFields.Text == "") { System.Windows.Forms.MessageBox.Show("You have not selected a field."); Cursor.Current = Cursors.Default; return; } //Check value has been entered in operator combo if (cboOperator.Text == "") { System.Windows.Forms.MessageBox.Show("You have not selected an operator."); Cursor.Current = Cursors.Default; return; } //Check value has been entered in value textbox if (txtValue.Text == "") { System.Windows.Forms.MessageBox.Show("You have not entered a query value."); txtValue.Focus(); Cursor.Current = Cursors.Default; return; } //Get layer to query ARMap arMap = axArcReaderControl1.ARPageLayout.FocusARMap; ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex]; //Build the ARSearchDef ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass(); //Build WhereClause that meets search criteria string sWhereClause; //Remove quotes from WhereClause if search is numeric if (optNumber.Checked == true) { sWhereClause = cboFields.Text + " " + cboOperator.Text + " " + txtValue.Text; } else { sWhereClause = cboFields.Text + " " + cboOperator.Text + " '" + txtValue.Text + "'"; } arSearchDef.WhereClause = sWhereClause; //Get ARFeatureSet that meets the search criteria m_arFeatureSetMeets = arLayer.QueryARFeatures(arSearchDef); //Build WhereClause that fails search criteria //Remove quotes from WhereClause if search is numeric if (optNumber.Checked == true) { sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " " + txtValue.Text; } else { sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " '" + txtValue.Text + "'"; } arSearchDef.WhereClause = sWhereClause; //Get ARFeatureSet that fails search criteria m_arFeatureSetFails = arLayer.QueryARFeatures(arSearchDef); //Reset mouse cursor Cursor.Current = Cursors.Default; //Populate the DataGrid Controls with the ARFeatureSets PopulateFlexGrids(dataGridView1, m_arFeatureSetMeets); PopulateFlexGrids(dataGridView2, m_arFeatureSetFails); //Give the user some feedback regarding the number of features that meet criteria if (m_arFeatureSetMeets.ARFeatureCount > 0) { EnableMeetHighlightTools(true); lblMeets.Text = "Features MEETING the search criteria: " + m_arFeatureSetMeets.ARFeatureCount.ToString(); } else { EnableMeetHighlightTools(false); dataGridView1.Rows.Clear(); lblMeets.Text = "Features MEETING the search criteria: 0"; } if (m_arFeatureSetFails.ARFeatureCount > 0) { EnableFailHighlightTools(true); lblFails.Text = "Features FAILING the search criteria: " + m_arFeatureSetFails.ARFeatureCount.ToString(); } else { EnableFailHighlightTools(false); dataGridView2.Rows.Clear(); lblMeets.Text = "Features FAILING the search criteria: 0"; } }
private void cmdQuery_Click(object sender, System.EventArgs e) { //Set mouse cursor as this can take some time with large datasets Cursor.Current = Cursors.WaitCursor; //Check value has been entered in field combo if (cboFields.Text == "") { System.Windows.Forms.MessageBox.Show("You have not selected a field."); Cursor.Current = Cursors.Default; return; } //Check value has been entered in operator combo if (cboOperator.Text == "") { System.Windows.Forms.MessageBox.Show("You have not selected an operator."); Cursor.Current = Cursors.Default; return; } //Check value has been entered in value textbox if (txtValue.Text == "") { System.Windows.Forms.MessageBox.Show("You have not entered a query value."); txtValue.Focus(); Cursor.Current = Cursors.Default; return; } //Get layer to query ARMap arMap = axArcReaderControl1.ARPageLayout.FocusARMap; ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex]; //Build the ARSearchDef ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass(); //Build WhereClause that meets search criteria string sWhereClause; //Remove quotes from WhereClause if search is numeric if (optNumber.Checked == true) { sWhereClause = cboFields.Text + " " + cboOperator.Text + " " + txtValue.Text; } else { sWhereClause = cboFields.Text + " " + cboOperator.Text + " '" + txtValue.Text + "'"; } arSearchDef.WhereClause = sWhereClause; //Get ARFeatureSet that meets the search criteria m_arFeatureSetMeets = arLayer.QueryARFeatures(arSearchDef); //Build WhereClause that fails search criteria //Remove quotes from WhereClause if search is numeric if (optNumber.Checked == true) { sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " " + txtValue.Text; } else { sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " '" + txtValue.Text + "'"; } arSearchDef.WhereClause = sWhereClause; //Get ARFeatureSet that fails search criteria m_arFeatureSetFails = arLayer.QueryARFeatures(arSearchDef); //Reset mouse cursor Cursor.Current = Cursors.Default; //Populate the DataGrid Controls with the ARFeatureSets PopulateFlexGrids(dataGridView1, m_arFeatureSetMeets); PopulateFlexGrids(dataGridView2, m_arFeatureSetFails); //Give the user some feedback regarding the number of features that meet criteria if (m_arFeatureSetMeets.ARFeatureCount > 0) { EnableMeetHighlightTools(true); lblMeets.Text = "Features MEETING the search criteria: " + m_arFeatureSetMeets.ARFeatureCount.ToString(); } else { EnableMeetHighlightTools(false); dataGridView1.Rows.Clear(); lblMeets.Text = "Features MEETING the search criteria: 0"; } if (m_arFeatureSetFails.ARFeatureCount > 0) { EnableFailHighlightTools(true); lblFails.Text = "Features FAILING the search criteria: " + m_arFeatureSetFails.ARFeatureCount.ToString(); } else { EnableFailHighlightTools(false); dataGridView2.Rows.Clear(); lblMeets.Text = "Features FAILING the search criteria: 0"; } }