Hi all
I've used sample "Bind a geodatabase table to .net control" to show attribute table of feature layers in a datagridview.
Now, i wanna update that datagridview when user selects some features in map and select corresponding rows.
Is there any code or sample for that? I've searched all internet but no help.
Regards
private void UpdateGridSelection(IFeatureLayer featureLayer,string oIDField) { try { //Clear Selection dataGridView1.ClearSelection(); //Get Selection set and populate Object IDs in List IFeatureSelection pFeatureSelection = featureLayer as IFeatureSelection; ISelectionSet pSelectionSet = pFeatureSelection.SelectionSet; IEnumIDs IDsEnum = pSelectionSet.IDs; int Id = -1; Id = IDsEnum.Next(); List<int> IdList = new List<int>(); while (Id != -1) { IdList.Add(Id); Id = IDsEnum.Next(); } //Select Rows Matches Selected Features By Its Object ID if (IdList.Count > 0) { var rows = from row in dataGridView1.Rows.Cast<DataGridViewRow>() where IdList.Contains(Convert.ToInt32(row.Cells[oIDField].Value)) select row; foreach (var item in rows) { item.Selected = true; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }