<?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: Use OnCreateFeature Event when adding a new feature in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103142#M20385</link>
    <description>&lt;P&gt;Thanks for the suggestion Brent.&amp;nbsp; Below is the code I ended up using to update the feature attribute with just static text.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;void EventListener_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            IFeature pFeat = (IFeature)obj;
            pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = "xxxxxx";
            pFeat.Store();
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of where the ComboBox I didn't really explain things as well as I should have.&lt;/P&gt;&lt;P&gt;Below is a screenshot from Visual Studio...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CarlBrydon_0-1632930443922.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/24151iC765A2F75BC5E595/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CarlBrydon_0-1632930443922.png" alt="CarlBrydon_0-1632930443922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FeatureCodeList.cs is the code generated by the AddInWizard for the ComboBox.&amp;nbsp; I need to reference the ComboBox (defined within FeatureCodeList.cs) in EventListener_OnCreateFeature which is in EventListener.cs.&amp;nbsp; So instead of the line...&lt;/P&gt;&lt;P&gt;pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = "xxxxxx";&lt;/P&gt;&lt;P&gt;I need to have...&lt;/P&gt;&lt;P&gt;pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = ComboxBox.CurrentValue (or whatever the correct syntax is);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Sep 2021 15:52:18 GMT</pubDate>
    <dc:creator>CarlBrydon</dc:creator>
    <dc:date>2021-09-29T15:52:18Z</dc:date>
    <item>
      <title>Use OnCreateFeature Event when adding a new feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1102557#M20383</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am putting together a c# Add-In using Visual Studio Community 2019.&amp;nbsp; I also have a ComboBox int he Add-In containing a list of feature codes being read from a dbase table.&lt;/P&gt;&lt;P&gt;I'd like to be able to do the following...&lt;/P&gt;&lt;P&gt;Whenever a new feature is created in any of the layers in my current MXD, populate a field on the feature just created with the current value of the ComboBox.&lt;/P&gt;&lt;P&gt;I am not sure how to get the name of the ComboBox control and reference it another *.cs file.&lt;/P&gt;&lt;P&gt;I am aware of the the Editing_EditEventListener sample, but there is more to that solution than I really need.&amp;nbsp; I tried copying the EventListener.cs file from that solution and adding it to my own project (I removed the portions of code referring to events other than OnCreateFeature to make it easier to read). I added the code below to EventListener_OnCreateFeature, but nothing happens when I do that.&amp;nbsp; Perhaps I need more than just the EventListener.cs file from the Developer sample?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IEditLayers ieLayers = (IEditLayers)m_editor;
IFeatureLayer pFLayer = ieLayers.CurrentLayer;
IFeatureCursor pFCur = pFLayer.Search(null, false);
IFeature pFeat = pFCur.NextFeature();
m_editor.StartOperation();
//  use dummy value until I can get the ComboBox Value
pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = "xxxxxx";
pFeat.Store();
m_editor.StopOperation("FeatureCodeUpdate");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't doubt there are flaws in the code I've added, but I believe the first step is getting the OnCreateFeature editor event to listen and fire whenever a new feature is added.&amp;nbsp; Hoping someone can get me pointed in the right direction.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 14:10:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1102557#M20383</guid>
      <dc:creator>CarlBrydon</dc:creator>
      <dc:date>2021-09-28T14:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Use OnCreateFeature Event when adding a new feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103129#M20384</link>
      <description>&lt;P&gt;Your IFeature interface can cast to IRowEvents where there is an OnNew and OnChanged event that you might be able to set up.&amp;nbsp; I haven't tried it, but it might work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you saying that the combo box is in a dll that you cannot edit and so create a public property in?&amp;nbsp; It is difficult to understand what the actual issue is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brent Hoskisson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 15:42:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103129#M20384</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2021-09-29T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use OnCreateFeature Event when adding a new feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103142#M20385</link>
      <description>&lt;P&gt;Thanks for the suggestion Brent.&amp;nbsp; Below is the code I ended up using to update the feature attribute with just static text.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;void EventListener_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            IFeature pFeat = (IFeature)obj;
            pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = "xxxxxx";
            pFeat.Store();
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of where the ComboBox I didn't really explain things as well as I should have.&lt;/P&gt;&lt;P&gt;Below is a screenshot from Visual Studio...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CarlBrydon_0-1632930443922.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/24151iC765A2F75BC5E595/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CarlBrydon_0-1632930443922.png" alt="CarlBrydon_0-1632930443922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FeatureCodeList.cs is the code generated by the AddInWizard for the ComboBox.&amp;nbsp; I need to reference the ComboBox (defined within FeatureCodeList.cs) in EventListener_OnCreateFeature which is in EventListener.cs.&amp;nbsp; So instead of the line...&lt;/P&gt;&lt;P&gt;pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = "xxxxxx";&lt;/P&gt;&lt;P&gt;I need to have...&lt;/P&gt;&lt;P&gt;pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = ComboxBox.CurrentValue (or whatever the correct syntax is);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 15:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103142#M20385</guid>
      <dc:creator>CarlBrydon</dc:creator>
      <dc:date>2021-09-29T15:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use OnCreateFeature Event when adding a new feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103452#M20390</link>
      <description>&lt;P&gt;You will have to edit FeatureCodeList.cs to expose the value of the combo box publicly:&lt;/P&gt;&lt;P&gt;public string ComboValue&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;get { return ComboBox.SelectedItem; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Now, it whatever class calls this method, you just need to get the value and put it in a place where the EventListener can find it.&amp;nbsp; I can't give you more specifics without seeing the code that starts up the combo box form.&amp;nbsp; However, it is all basic programming from here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 12:45:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103452#M20390</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2021-09-30T12:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use OnCreateFeature Event when adding a new feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103899#M20391</link>
      <description>&lt;P&gt;Thanks Brent,&lt;/P&gt;&lt;P&gt;I had a bit of help from&amp;nbsp;&lt;SPAN&gt;Éric G as ESRI Canada as well and had to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;expose the Combox Box as a field in FeatureCodeList class.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static FeatureCodeList s_combobox;
s_combobox = this;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Then using code similar to what you provided&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; internal static string  GetSelectedValue()
        {
            return s_combobox.Value;
        }  &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally within the EventListener.cs code, I defined the OnCreateFeature event as follows...&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;void EventListener_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
{
IFeature pFeat = (IFeature)obj;
pFeat.Value[pFeat.Fields.FindField("FEAT_CODE")] = FeatureCodeList.GetSelectedValue();
pFeat.Store();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your assistance with this!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Carl&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 11:42:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/use-oncreatefeature-event-when-adding-a-new/m-p/1103899#M20391</guid>
      <dc:creator>CarlBrydon</dc:creator>
      <dc:date>2021-10-01T11:42:13Z</dc:date>
    </item>
  </channel>
</rss>

