<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to automate a default style when loading an SQL database? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195439#M5098</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have never tried to hook into the Style Manager to change the symbology of features in a layer. This &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/LayerRendering/0048000000t4000000/"&gt;sample&lt;/A&gt;&lt;SPAN&gt; page appears to do this. You will need to read about the interface &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IStyleGallery.&lt;/SPAN&gt;&lt;SPAN&gt; Of cause I'm sure you are not the first to ask this question, try the Archived forums, here is one such &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=115195"&gt;thread&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jan 2014 16:12:56 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2014-01-06T16:12:56Z</dc:date>
    <item>
      <title>How to automate a default style when loading an SQL database?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195436#M5095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I create a new personal geodatabase and load the data into ArcMap the symbols for my spatial objects are always pulled from my custom style without problem. However, when I do the same thing with an SQL database the symbols are never correct. I understand this is because the SQL layers have a fully qualified names and don't match that of the custom style. But what is the best way to approach a fix for this issue? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to be able to add any SQL database to an ArcMap session and have my symbols assigned correctly to the the individual layers. Is there a way to update my custom style's layer names to match the fully qualified name of the SQL database? Is there a way to loop through the layers in the map and make sure the assigned symbol is correct and if not assign it the correct symbol from a custom style file? Any example code would be very much appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcGIS 10.2, C#, Windows 7, VS 2010/12&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank You&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Dec 2013 20:36:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195436#M5095</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2013-12-31T20:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate a default style when loading an SQL database?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195437#M5096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is one approach, written in VBA. You create your symbology in ArcMap and then save that to a LayerFile. You can then open that LayerFile and get the renderer and overwrite the renderer of the same layer in the map document. This works for file and personal geodatabases but I have not tested it on a SQL database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Public Sub LoadALayerFile()
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Path to Layer file&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sPath As String
&amp;nbsp;&amp;nbsp;&amp;nbsp; Let sPath = "C:\Scratch\CITIES_pop.lyr"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Open layerFile&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayerFile As ILayerFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pLayerFile = New LayerFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; pLayerFile.Open sPath
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get a handle on the layer in the LayerFile and its symbology&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As ILayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pLayer = pLayerFile.Layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pGeoFeatureLayer As IGeoFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pGeoFeatureLayer = pLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureRenderer As IFeatureRenderer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeatureRenderer = pGeoFeatureLayer.Renderer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get a handle on the layer in map that is the same as what LayerFile is using&lt;/SPAN&gt;
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Assumed to be first in TOC&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXD As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXD = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMap = pMXD.FocusMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pLayer = pMap.Layer(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Overwrite renderer&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pGeoFeatureLayer = pLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pGeoFeatureLayer.Renderer = pFeatureRenderer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN style="color:#008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Update and refresh map&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pMXD.UpdateContents
&amp;nbsp;&amp;nbsp;&amp;nbsp; pMXD.ActiveView.Refresh
End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:46:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195437#M5096</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-11T09:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate a default style when loading an SQL database?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195438#M5097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Duncan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the interest in my problem and for the suggested solution. The one thing I see as an issue with this approach is that I would be required to include the layer files as part of my solutions installation. I'd rather not include any additional files if at all possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there no ArcObjects approach that can retrieve the symbology from the "Style" file and assign it to a layer? Or, is there a way to alter the file path of the symbology to include the fully qualified path?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 15:04:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195438#M5097</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2014-01-06T15:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate a default style when loading an SQL database?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195439#M5098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have never tried to hook into the Style Manager to change the symbology of features in a layer. This &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/LayerRendering/0048000000t4000000/"&gt;sample&lt;/A&gt;&lt;SPAN&gt; page appears to do this. You will need to read about the interface &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;IStyleGallery.&lt;/SPAN&gt;&lt;SPAN&gt; Of cause I'm sure you are not the first to ask this question, try the Archived forums, here is one such &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=115195"&gt;thread&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 16:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-automate-a-default-style-when-loading-an/m-p/195439#M5098</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-01-06T16:12:56Z</dc:date>
    </item>
  </channel>
</rss>

