Linking the attribute table data to a text box

327
3
12-15-2011 06:38 AM
DavidTemplar1
New Contributor
Hello. I am new to ArcObjects and programming. I am trying to create a form that is initiated by a button click that when entering two streets in separate textboxes, the intersection of these two streets is zoomed in on in ArcMap (version 9.3.1). I have created the form where it will open and close but am stuck on where to go from here so that when street names are entered into a textbox, the street name is pulled from the Street shapefile's attribute table. Any help would be appreciated!!
(See attachment)
0 Kudos
3 Replies
DuncanHornby
MVP Frequent Contributor
Are you saying that you want drop-down lists of street names that the user can select? If so you want to be using a COMBOBOX not a TEXTBOX, the logic is:

  • Get a handle on the Map (IMap)

  • Get a handle on the layer (ILayer)

  • Create a point of type IFeaturelayer to your Layer

  • Get the Featureclass of the FeatureLayer

  • Create a FeatureCursor over entire FeatureClass

  • Step through Each Feature reading street name field

  • Add the street name to a list ensuring it's not duplicated, you could use a dictionary for this

  • Write the contents of the dictionary to a COMBOBOX

0 Kudos
DavidTemplar1
New Contributor
No, I didn't want to use a ComboBox because I have several hundred streets to select from. I was hoping I could use a text box so that the user can enter the streets they want to find and the text box would somehow be linked to the Street layer attribute table, specifically the ROADNAME field within the attribute table.
0 Kudos
DuncanHornby
MVP Frequent Contributor
Well the logic is not that dissimilar. You still need to get a handle on the FeatureClass and use a FeatureCursor to query your dataset by setting the WhereClause. This would return the feature or "row" where you could extract the geometry and zoom to it.

But you are opening up a can of worms here.  "Bob Street" is not the same as "bob st." or even "Bob Stret". Can you rely on your users entering the correct text? I can answer that now, no!

I'm sure someone could add stuff to this thread about using regularly expressions?
0 Kudos