<?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: Howto save to and restore from file the featurelayer's IFeatureSelection properti in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19468#M479</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks Robert for your reply.&lt;BR /&gt;&lt;BR /&gt;I could try to store the layer properties in a .lyr-file, but that gives a lot of overhead, and it takes time to open a .lyr-file, as it contains also a reference to the source (if the source can't be found, the symbology is invalid).&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We have about a dozen applications that add layers to the map for storing program output.&amp;nbsp; Each of these layers gets its symbology from a layer file that installs with the app.&amp;nbsp; Opening the layer file takes very little time and the symbology is not invalid.&amp;nbsp; You simply get the layer from the file, use IObjectCopy to clone its renderer and assign that renderer to the layer.&amp;nbsp; The code below is for a raster layer but it can be modified to work for a feature layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim layerFile As ILayerFile = New LayerFile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerFile.Open(layerFilePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim templateLayer As ILayer = layerFile.Layer()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objectCopy As IObjectCopy = New ObjectCopy
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim renderer As IRasterRenderer = DirectCast(objectCopy.Copy(DirectCast(templateLayer, IRasterLayer).Renderer), IRasterRenderer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterLayer.Renderer = renderer
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will work as long as the renderer properties are valid for the layer you're assigning it to (i.e. field names match, etc.).&amp;nbsp; While I haven't specifically tried it, it should be possible to copy the layer's selection settings as these settings are part of the serialized layer object stored in the layer file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:46:34 GMT</pubDate>
    <dc:creator>NeilClemmons</dc:creator>
    <dc:date>2021-12-10T20:46:34Z</dc:date>
    <item>
      <title>Howto save to and restore from file the featurelayer's IFeatureSelection properties</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19465#M476</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;BR /&gt;&lt;SPAN&gt;Like symbology, I would like to save to and restore from file the featurelayer's IFeatureSelection properties. This properties are set on the FeatureLayerSelectionPropertyPage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can do it (save to file) with the featurelayer's symbology with&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-size: 2; font-family: courier new;"&gt;IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;&lt;BR /&gt;&lt;BR /&gt;IMemoryBlobStream memoryBlobStream = new MemoryBlobStreamClass();&lt;BR /&gt;IObjectStream objectStream = new ObjectStreamClass();&lt;BR /&gt;objectStream.Stream = (IMemoryBlobStream)memoryBlobStream;&lt;BR /&gt;IPropertySet propertySet = new PropertySet();&lt;BR /&gt;IPersistStream persistStream = (IPersistStream)propertySet;&lt;BR /&gt;&lt;BR /&gt;propertySet.SetProperty("&lt;/SPAN&gt;&lt;SPAN style="color: #ff0000; font-size: 2; font-family: courier new;"&gt;Symbology&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 2; font-family: courier new;"&gt;", geoFeatureLayer.Renderer);&lt;BR /&gt;persistStream.Save(objectStream, 0);&lt;BR /&gt;memoryBlobStream.SaveToFile(filePath);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but for the featureselection I can't find anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody know how to do it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pieter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 12:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19465#M476</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2014-06-27T12:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19466#M477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's an even simpler method for saving your layer's symbology:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ILayerFile lyrFile = new LayerFile();
lyrFile.New("mylayer.lyr");
lyrFile.ReplaceContents(featureLayer);
lyrFile.Save();
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then to load it back up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ILayerFile lyrFile = new LayerFile();
lyrFile.Open("mylayer.lyr");
IFeatureLayer featureLayer = lyrFile.Layer;
ArcMap.Document.AddLayer(featureLayer);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for the selection set, that's not really something that has a built in method for saving. But that doesn't mean you can't create your own. The IFeatureSelection.SelectionSet is where all the OIDs of the selected features are stored. If you just save those OIDs, then you can easily retrieve them and update the IFeatureSelection.SelectionSet to contain those same OIDs when you load your layer back up. For example, add the following to the end of the above two blocks of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//Save selection set after saving .lyr file
IFeatureSelection featSel = featureLayer as IFeatureSelection;
IEnumIDs enumIDs = featSel.SelectionSet.IDs;
List&amp;lt;int&amp;gt; listIDs = new List&amp;lt;int&amp;gt;();
int id = enumIDs.Next();
while (id &amp;gt; -1)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; listIDs.Add(id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; id = enumIDs.Next();
}
System.IO.File.WriteAllText("mylayer.set", string.Join(",", listIDs));
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//Load selection set after loading .lyr file
IFeatureSelection featSel = featureLayer as IFeatureSelection;
ISelectionSet selSet = featSel.SelectionSet;
IEnumerable&amp;lt;string&amp;gt; strIDs = System.IO.File.ReadAllText("mylayer.set").Split(',');
int id;
foreach (string strID in strIDs)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (int.TryParse(strID, out id))
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selSet.Add(id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
featSel.SelectionChanged();
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you'll have one file "mylayer.lyr" that contains all your symbology and stuff, and another file "mylayer.set" that contains the OIDs of your selected features. Additionally, if you want to have it all in one file and are on an NTFS partition, you can use NTFS File Streams (&lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx&lt;/A&gt;&lt;SPAN&gt;) to store it in the same file by simply changing "mylayer.set" to "mylayer.lyr:selection"!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19466#M477</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2021-12-10T20:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19467#M478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Robert for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My program reads a XML-file with the names the FeatureClasses to load (several sub-projects with the same kind of data but for multiple users on different locations). Then it creates FeatureLayers based on the FeatureClasses, with the symbology stored in binary files as described above, and, as I would like to do, also the ISymbol which is used to show the selected features (IFeaturelayer -&amp;gt; IFeatureSelection -&amp;gt; SelectionSymbol), but I don't need to store/retrieve a selectionset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could try to store the layer properties in a .lyr-file, but that gives a lot of overhead, and it takes time to open a .lyr-file, as it contains also a reference to the source (if the source can't be found, the symbology is invalid).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have a nice day,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pieter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 08:13:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19467#M478</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2014-07-01T08:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19468#M479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks Robert for your reply.&lt;BR /&gt;&lt;BR /&gt;I could try to store the layer properties in a .lyr-file, but that gives a lot of overhead, and it takes time to open a .lyr-file, as it contains also a reference to the source (if the source can't be found, the symbology is invalid).&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We have about a dozen applications that add layers to the map for storing program output.&amp;nbsp; Each of these layers gets its symbology from a layer file that installs with the app.&amp;nbsp; Opening the layer file takes very little time and the symbology is not invalid.&amp;nbsp; You simply get the layer from the file, use IObjectCopy to clone its renderer and assign that renderer to the layer.&amp;nbsp; The code below is for a raster layer but it can be modified to work for a feature layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim layerFile As ILayerFile = New LayerFile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerFile.Open(layerFilePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim templateLayer As ILayer = layerFile.Layer()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objectCopy As IObjectCopy = New ObjectCopy
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim renderer As IRasterRenderer = DirectCast(objectCopy.Copy(DirectCast(templateLayer, IRasterLayer).Renderer), IRasterRenderer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterLayer.Renderer = renderer
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will work as long as the renderer properties are valid for the layer you're assigning it to (i.e. field names match, etc.).&amp;nbsp; While I haven't specifically tried it, it should be possible to copy the layer's selection settings as these settings are part of the serialized layer object stored in the layer file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:46:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19468#M479</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2021-12-10T20:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19469#M480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah, sorry for misunderstanding your question, Pieter. And thank you for clearly explaining where I missed it. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can also vouch for what Neil said. I've pulled the symbology from lyr files that were generated on a different machine using datasets that don't exist on the current machine, but have the same basic structure, and it does work. (More specifically, the layers that I'm loading the symbology into are actually created by my Add-in, so I always know that they are going to have the same structure.) Check out the following code which is a modification of the code that I posted earlier (Note that featureLayer would be the IFeatureLayer that you are wanting to set the symbology for, and that the layer loaded from the file is NOT added to the map):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;ILayerFile lyrFile = new LayerFile(); lyrFile.Open("mylayer.lyr"); IGeoFeatureLayer storedGeoLayer = lyrFile.Layer as IGeoFeatureLayer; IGeoFeatureLayer targetGeoLayer = featureLayer as IGeoFeatureLayer; targetGeoLayer.Renderer = storedGeoLayer.Renderer; //Force the table of contents and currently drawn map to refresh using the new symbology ArcMap.Document.UpdateContents(); ArcMap.Document.ActiveView.Refresh();&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should work without any problems, as long as the fields used for the symbology (if any) are the same in both datasets. I don't know for certain that the Selection Symbol would be stored to the lyr file, but if it is, you should probably be able to get to it by inserting the following code before the comment in the previous code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;IFeatureSelection storedSelProps = storedGeoLayer as IFeatureSelection; IFeatureSelection targetSelProps = targetGeoLayer as IFeatureSelection; targetSelProps.SelectionSymbol = storedSelProps.SelectionSymbol;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would say that you should just try and see if it works. If it throws an error, set a breakpoint and walk through it to find where it fails. If it doesn't throw an error, but doesn't change the Selection Symbol, then I would try just loading a lyr file that was created with a custom Selection Symbol and see if it loads it back up the same way to see if it even stores it in the lyr file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck with that and let us know how it goes! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 00:22:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19469#M480</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2014-07-02T00:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19470#M481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Robby and Neil.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have now this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family:courier new;"&gt;private IFeatureLayer FeatureLayerFromFeatureClass(IFeatureClass featureClass, string layername)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureLayer featureLayer = new FeatureLayerClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.Name = layerName;
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.FeatureClass = featureClass;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureSelection featureSelection = featureLayer as IFeatureSelection;

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (File.Exists(_layerFilePath))
&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // open the layer from the .lyr-file
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ILayerFile layerFile = new LayerFileClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerFile.Open(_layerFilePath);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer sourceGeoFeatureLayer = layerFile.Layer as IGeoFeatureLayer;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // destination
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer destinationGeoFeatureLayer = featureLayer as IGeoFeatureLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // copier
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IObjectCopy objectCopy = new ObjectCopyClass();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get the symbology
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureRenderer featureRenderer = objectCopy.Copy(sourceGeoFeatureLayer.Renderer) as IFeatureRenderer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationGeoFeatureLayer.Renderer = featureRenderer;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get the feature selectionsymbol
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IFeatureSelection sourceFeatureSelection = sourceGeoFeatureLayer as IFeatureSelection;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SelectionSymbol = objectCopy.Copy(sourceFeatureSelection.SelectionSymbol) as ISymbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureSelection.SetSelectionSymbol = true;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // close nicely
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerFile.Close();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return featureLayer;
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and it retrieves the symbology but &lt;/SPAN&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;SPAN&gt; the selectionsymbol.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{edited} I adapted the .lyr-files in ArcCatalog and selected a custom symbol, but when I open the FeatureLayerSelectionPropertyPage in the program it is the default symbol, what I don't want. {/edited}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:46:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19470#M481</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2021-12-10T20:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Howto save to and restore from file the featurelayer's IFeatureSelection properti</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19471#M482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After reviewing the code, I've found an overseen piece that did reset the selectionsymbol.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, the above code works for &lt;/SPAN&gt;&lt;STRONG&gt;both&lt;/STRONG&gt;&lt;SPAN&gt; featurerenderer and selectionsymbol.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thank for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 12:46:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/howto-save-to-and-restore-from-file-the/m-p/19471#M482</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2014-07-02T12:46:27Z</dc:date>
    </item>
  </channel>
</rss>

