Att Items From Attribute Table To Combobox

648
1
05-01-2013 07:19 AM
geomatic
New Contributor
Hello Experts,

I am working on a Project that includes homes with customers and some specialities of buildings in attribute table.

First Of All I want to make a queries with using customers' names to zoom in customers' houses. I want to add customer name attributes from table to combobox and display selected features on map with zooming. (customer's names will take part in joined table)

Secondly i would like to add new attribute queries if requires. (not required but if i can i will query like "select from attributes" Customer Name: Tolga Ozdemir Floors: 3 etc.)

How can i perform with using Visual Basic for adding my attributes (customers name) to combobox? I have been searching for sample codes but i couldn't find it clearly.

Thanks for your help.

Tolga Ozdemir
0 Kudos
1 Reply
BarbaraSchneider1
New Contributor III
Hi Tolga,

you can find a code sample to query a table or feature class at:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Querying_geodatabase_ta...

A code sample to query joined data is at:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Joining_data/0001000002...

Code in VB:
       
        Dim pMxDoc As IMxDocument
        Dim pMap As IMap
        Dim pFeatLayer As IFeatureLayer
        Dim pFeatClass As IFeatureClass
        Dim pDataset As IDataset
        Dim pFeatWorkspace As IFeatureWorkspace
        Dim pQueryDef As IQueryDef
        Dim pCursor As ICursor
        Dim pRow As IRow
        Dim pName As String
        Dim pNameIndex As Integer

        ' Get feature class
        pMxDoc = My.ArcMap.Document
        pMap = pMxDoc.FocusMap
        pFeatLayer = pMap.Layer(0)
        pFeatClass = pFeatLayer.FeatureClass

        ' Create query definition (for joined attributes)
        pDataset = pFeatClass
        pFeatWorkspace = pDataset.Workspace
        pQueryDef = pFeatWorkspace.CreateQueryDef
        pQueryDef.Tables = "Punkte, Names" ' Name of joined tables
        pQueryDef.SubFields = "Names.Name" ' Field I want tow query
        pQueryDef.WhereClause = "Punkte.OBJECTID = Names.ID" ' Join condition
        pCursor = pQueryDef.Evaluate()
        pNameIndex = pCursor.FindField("Names.Name") 'Index of field I want to query

        ' Step through rows (features)
        pRow = pCursor.NextRow()
        While Not pRow Is Nothing
            pName = pRow.Value(pNameIndex)
            'Add name to combo box
            pComboBox.Items.Add()

            pRow = pCursor.NextRow()
        End While
0 Kudos