Select to view content in your preferred language

list values from a field in combo box, zoom to selection using arcGIS Pro SDK C#

1428
7
Jump to solution
04-10-2023 10:41 PM
AntEsk
by
New Contributor II

i am trying to replicate a simple python addin i had, it would populate a dropdown with a list of values from a feature class and zoom to the selected value(for example states), i am new to the arcGIS Pro SDK and i cant even figure out how to make a list of all the values in a field.  Featureclass is in a file geodatabse, 

How can i get a list of values from a feature class?

then how would i zoom the active map to the extent of that feature?

0 Kudos
2 Solutions

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I attached a sample with a drop down list of features, however, the features are extracted from a feature layer  (specifically the States layer) not a feature class.  You can change the code by using @MatthewDriscoll  's snippet in order to get the drop down list data from a feature class.

I would also suggest that you get familiar with the Pro SDK you can find the Pro SDK landing page here:

ArcGIS Pro SDK | Documentation

As data for the attached sample i used the 'C:\Data\Admin\AdminSample.aprx' project & data which is distributed through the community samples release page (see link above).

Wolf_0-1681319717718.png

 

View solution in original post

Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry about that, i created this sample in my attachment above for the 3.2 community sample release.  To get it to work with ArcGIS Pro 3.0 or 3.1, you have to change the minimum desktop version of the add-in in the config.daml:

Change this line in config.daml:

<AddInInfo id="{b69d8233-0ca5-49ea-adc4-80ad26e2a8ed}" version="1.0" desktopVersion="3.2.48119">

To the following in order for the add-in to work with release 3.0 of ArcGIS Pro:

<AddInInfo id="{b69d8233-0ca5-49ea-adc4-80ad26e2a8ed}" version="1.0" desktopVersion="3.0.0">

 

View solution in original post

7 Replies
MatthewDriscoll
MVP Alum

Get values and populate dropdown.

 

QueryFilter queryDef = new QueryFilter
                    {

                        SubFields = "field"
                    };                    

List<String> listbld = new List<string>();


                    using (var rowCursor = FeatureTable.Search(queryDef, false))

                    {
                        while (rowCursor.MoveNext())
                        {
                            using (Row row = rowCursor.Current)
                            {

                                string data = Convert.ToString(row["field"]);

                                listbld.Add(data);

                            }
                        }
                    }
                    BldList = listbld;

 

 

Zoom

 

MapView.Active.ZoomToSelected(TimeSpan.FromSeconds(1.5), true);

 

AntEsk
by
New Contributor II

Thank you, that helps me understand the process

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I attached a sample with a drop down list of features, however, the features are extracted from a feature layer  (specifically the States layer) not a feature class.  You can change the code by using @MatthewDriscoll  's snippet in order to get the drop down list data from a feature class.

I would also suggest that you get familiar with the Pro SDK you can find the Pro SDK landing page here:

ArcGIS Pro SDK | Documentation

As data for the attached sample i used the 'C:\Data\Admin\AdminSample.aprx' project & data which is distributed through the community samples release page (see link above).

Wolf_0-1681319717718.png

 

AntEsk
by
New Contributor II

Thank you very much, 

0 Kudos
AntEsk
by
New Contributor II

i cant get the sample to work, i can build it and it will put an add-in folder into the correct folder but when arcgis pro opens during debugging there is no add-in menu with the add-in ? (image below)  i can get other add-ins to work, (combobox sample) is there some reference missing?

AntEsk_0-1681343067954.png

 

0 Kudos
AntEsk
by
New Contributor II

i got it to work by moving the contents of the SelectFeature class contents to the class i had in my combox sample that works, so i guess there is a reference missing?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry about that, i created this sample in my attachment above for the 3.2 community sample release.  To get it to work with ArcGIS Pro 3.0 or 3.1, you have to change the minimum desktop version of the add-in in the config.daml:

Change this line in config.daml:

<AddInInfo id="{b69d8233-0ca5-49ea-adc4-80ad26e2a8ed}" version="1.0" desktopVersion="3.2.48119">

To the following in order for the add-in to work with release 3.0 of ArcGIS Pro:

<AddInInfo id="{b69d8233-0ca5-49ea-adc4-80ad26e2a8ed}" version="1.0" desktopVersion="3.0.0">