No symbols in referenced styles after loading a QueryDef FeatureClass

8071
12
10-07-2011 06:41 AM
karinweixler
New Contributor II
Hello,
after loading a QueryDef FeatureClass per Code (with IFeatureWorkspace.CreateQueryDef and .OpenFeatureQuery) and open the Layer Properties and the Tab Symbology, there are no Symbols loaded in the Symbol Selector if i wont to change the Style of my used Symbol, even there are some Style References by default (ESRI). The solution at the moment is to open the Style References check any of the Style Refernce and click ok. After that there are the default Style References loaded. Does someone has the same expirience with loaded QueryDef FeatureClasses? Back in ArcGIS 9.3 everything worked fine. Now with ArcGIS 10 SP 1 i have this strange behavior. Is there a differnt way now with ArcGIS 10 to load just a part of a FeatureClass then using CreateQueryDef?
Thanks in advance.
Karin
0 Kudos
12 Replies
NeilClemmons
Regular Contributor III
I really don't see any reason why it wouldn't work properly.  Having a shared instance of a workspace object shouldn't affect anything I would think.  I personally wouldn't implement it that way since I wouldn't want an open connection to be hanging around any longer than I needed it but that's just a preference.  One thing you might try is to use the Activator class to instantiate the workspace factory.  Workspace factories are singleton objects and calling New can cause problems.

pWorkspaceFactory = CType(Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory")), IWorkspaceFactory)

Other than that, you may want to just get rid of the shared instance and call your function to open the workspace each time you need it.
0 Kudos
karinweixler
New Contributor II
Thanks again Neil for your help. Unfortunately using the Activator for the connection has no effect. So i gues i have to think about my shared connection, but that would be a bigger thing.
I tried also to open the Style Reference Dialog via Code, but i cant find the way to close it again via code. Do you have a hint for that?

'open the StyleReferencesDialog:
Dim styleGallery As IStyleGallery
styleGallery = pDoc.StyleGallery
Dim styleReferencesDialog As ESRI.ArcGIS.DisplayUI.IStyleDialog = New ESRI.ArcGIS.DisplayUI.StyleReferencesDialogClass()
styleReferencesDialog.DoModal(styleGallery, pApp.hWnd)
'how to close it (with the ok button) via code?
0 Kudos
RichWawrzonek
Occasional Contributor
Karin-
I would take Neil's advice and use the activator class to create singleton objects even if you don't see a difference in your shared workspace example. Further down the road it will likely cause issues as you make additional customizations to your program.

By the way- The IStyleGallery is also a singleton class. I think you should modify your code as follows:

Dim t As Type = Type.GetTypeFromProgID("esriFramework.StyleGallery")
Dim obj As System.Object = Activator.CreateInstance(t)
Dim styleGallery As ESRI.ArcGIS.Display.IStyleGallery = obj
styleGallery = pDoc.StyleGallery
Dim styleReferencesDialog As ESRI.ArcGIS.DisplayUI.IStyleDialog = New ESRI.ArcGIS.DisplayUI.StyleReferencesDialogClass()
styleReferencesDialog.DoModal(styleGallery, pApp.hWnd)

See ESRI documentation:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000043p000000
0 Kudos