Select to view content in your preferred language

Unable to see the objects in the map through arcengine code

842
3
04-30-2010 10:03 AM
MichaelWaits
Deactivated User
Hi everyone,

Very new to GIS so bear with my description of the problem.  I am coding in VS 2008 in VB.  I am trying to load up a geodatabase and show the contents on a mapcontrol, but the objects don't appear in the control when I add it through code.  I add the geodatabase through the Add Data toolbar button and the features appear on the map. 
My code follows and the geodatabase is attached.  Can anyone notice anything wrong with what I am doing?

        Dim objWorkspaceFactory As IWorkspaceFactory2
        Dim objGDBFeatureWorkspace As IFeatureWorkspace
        Dim objGDBFeatureLayer As IFeatureLayer

        objWorkspaceFactory = New FileGDBWorkspaceFactory
        objGDBFeatureLayer = New FeatureLayer

        objGDBFeatureWorkspace = CType(objWorkspaceFactory.OpenFromFile(strFilePath, 0), IFeatureWorkspace)
        objGDBFeatureLayer.FeatureClass = objGDBFeatureWorkspace.OpenFeatureClass("Site_Lots_TEST")
        objGDBFeatureLayer.Name = objGDBFeatureLayer.FeatureClass.AliasName
        AxMapControl1.AddLayer(objGDBFeatureLayer)
0 Kudos
3 Replies
JeffMatson
Frequent Contributor
All you should need to do is refresh the active view at the end of your code block:

AxMapControl1.ActiveView.Refresh()
0 Kudos
MichaelWaits
Deactivated User
I tried adding the refresh but to no avail.  I can have the layer added through code, and the layer added via the "Add Data" button, and only the layer from the button will show the objects.  Both have the underlying data available, it's just the map object which isn't appearing from the code added layer.
0 Kudos
JeffMatson
Frequent Contributor
I wasn't able to open the zip file so I couldn't test with your data...
Are you able to add other types of data (eg. Shapefile or PGDB)?
0 Kudos